Skip to content

Hovering an optional boolean param in strict mode shows param?: boolean | undefined #1600

@jakebailey

Description

@jakebailey

I suspect this has something to do with boolean secretly being true | false under the hood.

package fourslash_test

import (
	"testing"

	"github.com/microsoft/typescript-go/internal/fourslash"
	"github.com/microsoft/typescript-go/internal/testutil"
)

func TestHoverMethodOptionalParam(t *testing.T) {
	t.Parallel()
	defer testutil.RecoverAndFail(t, "Panic on fourslash test")
	const content = `
// @strict: true

class Foo {
	methodWith/*1*/OptionalParam(param?: boolean) {
		return param
	}
}
`
	f := fourslash.NewFourslash(t, nil /*capabilities*/, content)
	f.VerifyQuickInfoAt(t, "1", "(method) Foo.methodWithOptionalParam(param?: boolean): boolean | undefined", "")
}
--- FAIL: TestHoverMethodOptionalParam (0.05s)
    /home/jabaile/work/TypeScript-go/internal/fourslash/tests/fourslash.go:1350: At marker '1': Hover markdown content mismatch:
          (
          	"""
          	```tsx
        - 	(method) Foo.methodWithOptionalParam(param?: boolean | undefined): boolean | undefined
        + 	(method) Foo.methodWithOptionalParam(param?: boolean): boolean
          	```
          	"""
          )
FAIL
FAIL	github.com/microsoft/typescript-go/internal/fourslash/tests	0.056s
FAIL

Compare to:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: EditorRelated to the LSP server, editor experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions