Skip to content

Fix error baselines for empty files #1014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2025
Merged
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
3 changes: 1 addition & 2 deletions internal/testutil/tsbaseline/error_baseline.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ func iterateErrorBaseline(t *testing.T, inputFiles []*harnessutil.TestFile, inpu

// 'merge' the lines of each input file with any errors associated with it
dupeCase := map[string]int{}
nonEmptyFiles := core.Filter(inputFiles, func(f *harnessutil.TestFile) bool { return len(f.Content) > 0 })
for _, inputFile := range nonEmptyFiles {
for _, inputFile := range inputFiles {
// Filter down to the errors in the file
fileErrors := core.Filter(diagnostics, func(e *ast.Diagnostic) bool {
return e.File() != nil &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
a.js(8,16): error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b


==== checkJsdocTypeTagOnExportAssignment1.js (0 errors) ====

==== a.js (1 errors) ====
/**
* @typedef {Object} Foo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
b.js(2,16): error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b


==== checkJsdocTypeTagOnExportAssignment2.js (0 errors) ====

==== a.ts (0 errors) ====
export interface Foo {
a: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
a.js(10,16): error TS2739: Type '{ c: number; }' is missing the following properties from type 'Foo': a, b


==== checkJsdocTypeTagOnExportAssignment3.js (0 errors) ====

==== a.js (1 errors) ====
/**
* @typedef {Object} Foo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
a.js(6,16): error TS2352: Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.


==== checkJsdocTypeTagOnExportAssignment4.js (0 errors) ====

==== a.js (1 errors) ====
/**
* @typedef {number} Foo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

==== /tests/node_modules/@types/react/package.json (0 errors) ====
{ "name": "@types/react", "version": "16.4.6" }
==== /tests/node_modules/@types/react/index.d.ts (0 errors) ====

==== /node_modules/@types/react/package.json (0 errors) ====
{ "name": "@types/react", "version": "16.4.6" }
==== /node_modules/@types/react/index.d.ts (1 errors) ====
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@
import js from "./js"; // OK because it's an untyped module.
~~~~~~
!!! error TS2307: Cannot find module './js' or its corresponding type declarations.

==== /tsx.tsx (0 errors) ====

==== /jsx.jsx (0 errors) ====

==== /js.js (0 errors) ====

Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@
-!!! error TS6142: Module './jsx' was resolved to '/jsx.jsx', but '--jsx' is not set.
+!!! error TS2307: Cannot find module './jsx' or its corresponding type declarations.
import js from "./js"; // OK because it's an untyped module.
-
-==== /tsx.tsx (0 errors) ====
-
-==== /jsx.jsx (0 errors) ====
-
-==== /js.js (0 errors) ====
+ ~~~~~~
+!!! error TS2307: Cannot find module './js' or its corresponding type declarations.

==== /tsx.tsx (0 errors) ====

Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
import jsx from "./jsx";
~~~~~~~
!!! error TS2306: File '/jsx.jsx' is not a module.

==== /jsx.jsx (0 errors) ====

Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
import jsx from "./jsx";
~~~~~~~
!!! error TS2307: Cannot find module './jsx' or its corresponding type declarations.

==== /jsx.jsx (0 errors) ====

Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
+ import jsx from "./jsx";
+ ~~~~~~~
+!!! error TS2307: Cannot find module './jsx' or its corresponding type declarations.
+
+==== /jsx.jsx (0 errors) ====
+
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ requireOfAnEmptyFile1_a.ts(1,21): error TS2306: File 'requireOfAnEmptyFile1_b.ts
import fs = require('./requireOfAnEmptyFile1_b');
~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2306: File 'requireOfAnEmptyFile1_b.ts' is not a module.

==== requireOfAnEmptyFile1_b.ts (0 errors) ====

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ file1.ts(6,13): error TS2339: Property 'b' does not exist on type '{}'.
~
!!! error TS2339: Property 'b' does not exist on type '{}'.
}

==== b.json (0 errors) ====

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/a.js(2,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules.


==== plainJSGrammarErrors3.js (0 errors) ====

==== /a.js (1 errors) ====
function foo() {
await new Promise(undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@
+++ new.checkJsdocTypeTagOnExportAssignment1.errors.txt
@@= skipped -0, +0 lines =@@
-a.js(8,18): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'.
-
-
-==== checkJsdocTypeTagOnExportAssignment1.js (0 errors) ====
-
+a.js(8,16): error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b
+
+
==== a.js (1 errors) ====
/**
* @typedef {Object} Foo
@@= skipped -11, +9 lines =@@


==== checkJsdocTypeTagOnExportAssignment1.js (0 errors) ====
@@= skipped -11, +11 lines =@@

/** @type {Foo} */
export default { c: false };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@
+++ new.checkJsdocTypeTagOnExportAssignment2.errors.txt
@@= skipped -0, +0 lines =@@
-b.js(2,18): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Foo'.
-
-
-==== checkJsdocTypeTagOnExportAssignment2.js (0 errors) ====
-
+b.js(2,16): error TS2739: Type '{ c: boolean; }' is missing the following properties from type 'Foo': a, b
+
+
==== a.ts (0 errors) ====
export interface Foo {
a: number;
@@= skipped -11, +9 lines =@@


==== checkJsdocTypeTagOnExportAssignment2.js (0 errors) ====
@@= skipped -11, +11 lines =@@
==== b.js (1 errors) ====
/** @type {import("./a").Foo} */
export default { c: false };
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@
+++ new.checkJsdocTypeTagOnExportAssignment4.errors.txt
@@= skipped -0, +0 lines =@@
-a.js(6,16): error TS2322: Type 'string' is not assignable to type 'number'.
-
-
-==== checkJsdocTypeTagOnExportAssignment4.js (0 errors) ====
-
+a.js(6,16): error TS2352: Conversion of type 'string' to type 'number' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
+
+
==== a.js (1 errors) ====
/**
* @typedef {number} Foo
@@= skipped -10, +8 lines =@@


==== checkJsdocTypeTagOnExportAssignment4.js (0 errors) ====
@@= skipped -10, +10 lines =@@
/** @type {Foo} */
export default "";
~~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import jsx from "./jsx";
~~~~~~~
-!!! error TS6142: Module './jsx' was resolved to '/jsx.jsx', but '--jsx' is not set.
-
-==== /jsx.jsx (0 errors) ====
+!!! error TS2306: File '/jsx.jsx' is not a module.

==== /jsx.jsx (0 errors) ====

This file was deleted.