Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tsc/internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -15379,7 +15379,10 @@ func (c *Checker) getExternalModuleFileFromDeclaration(declaration *ast.Node) *a
if ast.HasImportAttributes(declaration) {
importAttributesType = c.getTypeFromImportAttributes(ast.GetImportAttributes(declaration))
}
moduleSymbol := c.resolveExternalModuleNameWorker(specifier, specifier /*moduleNotFoundError*/, nil, false, false, importAttributesType) // TODO: GH#18217
// This is only used by emit and type printing, after checking has already reported any
// resolution errors for this specifier. Resolve with ignoreErrors so that these queries
// don't add new diagnostics (e.g. an implicit-any-module suggestion) as a side effect.
moduleSymbol := c.resolveExternalModuleNameWorker(specifier, specifier, nil /*moduleNotFoundError*/, true /*ignoreErrors*/, false /*isForAugmentation*/, importAttributesType)
if moduleSymbol == nil {
return nil
}
Expand Down
3 changes: 3 additions & 0 deletions tsc/internal/fourslash/fourslash.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ const showCodeLensLocationsCommandName = "typescript.showCodeLensLocations"
func (f *FourslashTest) initialize(t *testing.T, capabilities *lsproto.ClientCapabilities, runExternalCode bool) {
initializationOptions := &lsproto.InitializationOptions{
CodeLensShowLocationsCommandName: new(showCodeLensLocationsCommandName),
// Make every textDocument/diagnostic request also emit the program and fail if the
// diagnostics differ before and after emit, e.g. because the emit resolver added some.
TrackFlakyDiagnostics: new(lsproto.DiagnosticFlakeLogLevelPanic),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this "builds up" on microsoft/typescript-go#4526 and microsoft/typescript-go#4710 . It feels the same unconditional flaky diagnostic tracking can just be added to fourslash. And it makes it easier to write tests for this without going full in on server-level tests

}
if runExternalCode {
initializationOptions.RunExternalCode = new(true)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/TypeScript/tsc/internal/fourslash"
"github.com/microsoft/TypeScript/tsc/internal/testutil"
)

func TestNoFlakyDiagnosticsUntypedModule1(t *testing.T) {
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `// @allowJs: true
// @noImplicitAny: true
// @declaration: true
// @Filename: /node_modules/untyped/index.js
// @noOpen: true
exports.x = 1;
// @Filename: /index.js
import { x } from "untyped";
x;`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.GoToFile(t, "/index.js")
f.VerifySuggestionDiagnostics(t, nil)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/TypeScript/tsc/internal/fourslash"
"github.com/microsoft/TypeScript/tsc/internal/testutil"
)

func TestNoFlakyDiagnosticsUntypedModule2(t *testing.T) {
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `// @noImplicitAny: true
// @declaration: true
// @Filename: /untyped.js
exports.x = 1;
// @Filename: /index.ts
// @ts-expect-error
import { x } from "./untyped";
x;`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.GoToFile(t, "/index.ts")
f.VerifySuggestionDiagnostics(t, nil)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package fourslash_test

import (
"testing"

"github.com/microsoft/TypeScript/tsc/internal/fourslash"
"github.com/microsoft/TypeScript/tsc/internal/testutil"
)

func TestNoFlakyDiagnosticsUntypedModule3(t *testing.T) {
t.Parallel()
defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `// @module: nodenext
// @noImplicitAny: true
// @declaration: true
// @Filename: /untyped.mjs
export const x = 1;
// @Filename: /index.mts
// @ts-expect-error
import { x } from "./untyped.mjs";
x;`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.GoToFile(t, "/index.mts")
f.VerifySuggestionDiagnostics(t, nil)
}