Skip to content
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
309 changes: 142 additions & 167 deletions internal/checker/checker.go

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions internal/checker/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,10 @@ type DeferredSymbolLinks struct {
// Links for alias symbols

type AliasSymbolLinks struct {
immediateTarget *ast.Symbol // Immediate target of an alias. May be another alias. Do not access directly, use `checker.getImmediateAliasedSymbol` instead.
aliasTarget *ast.Symbol // Resolved (non-alias) target of an alias
referenced bool // True if alias symbol has been referenced as a value that can be emitted
typeOnlyDeclarationResolved bool // True when typeOnlyDeclaration resolution in process
typeOnlyDeclaration *ast.Node // First resolved alias declaration that makes the symbol only usable in type constructs
typeOnlyExportStarName string // Set to the name of the symbol re-exported by an 'export type *' declaration, when different from the symbol name
immediateTarget *ast.Symbol // Immediate target of an alias. May be another alias. Do not access directly, use `checker.getImmediateAliasedSymbol` instead.
aliasTarget *ast.Symbol // Resolved (non-alias) target of an alias
referenced bool // True if alias symbol has been referenced as a value that can be emitted
typeOnlyDeclaration *ast.Node // First resolved alias declaration that makes the symbol only usable in type constructs
}

// Links for module symbols
Expand Down
3 changes: 0 additions & 3 deletions internal/compiler/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,15 +1041,12 @@ func (p *Program) getSemanticDiagnosticsForFileNotFilter(ctx context.Context, so
defer done()
}
diags := slices.Clip(sourceFile.BindDiagnostics())

// Ask for diags from all checkers; checking one file may add diagnostics to other files.
// These are deduplicated later.
checkerDiags := make([][]*ast.Diagnostic, p.checkerPool.Count())
p.checkerPool.ForEachCheckerParallel(ctx, func(idx int, checker *checker.Checker) {
if sourceFile == nil || checker == fileChecker {
checkerDiags[idx] = checker.GetDiagnostics(ctx, sourceFile)
} else {
checkerDiags[idx] = checker.GetDiagnosticsWithoutCheck(sourceFile)
}
})
if ctx.Err() != nil {
Expand Down
11 changes: 0 additions & 11 deletions internal/testrunner/compiler_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,19 +350,8 @@ func newCompilerTest(
}
}

var concurrentSkippedErrorBaselines = map[string]string{
"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.",
}

func (c *compilerTest) verifyDiagnostics(t *testing.T, suiteName string, isSubmodule bool) {
t.Run("error", func(t *testing.T) {
if !testutil.TestProgramIsSingleThreaded() {
if msg, ok := concurrentSkippedErrorBaselines[c.basename]; ok {
t.Skipf("Skipping in concurrent mode: %s", msg)
}
}

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{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
b.ts(2,12): error TS1380: An import alias cannot reference a declaration that was imported using 'import type'.
b.ts(3,13): error TS1380: An import alias cannot reference a declaration that was imported using 'import type'.
c.ts(2,12): error TS1380: An import alias cannot reference a declaration that was imported using 'import type'.
c.ts(3,13): error TS1380: An import alias cannot reference a declaration that was imported using 'import type'.


==== a.ts (0 errors) ====
Expand All @@ -21,16 +20,13 @@ c.ts(3,13): error TS1380: An import alias cannot reference a declaration that wa
const x = 0;
export { a, A, x };

==== c.ts (2 errors) ====
==== c.ts (1 errors) ====
import * as b from './b';
import A = b.a.A; // Error
~~~~~
!!! error TS1380: An import alias cannot reference a declaration that was imported using 'import type'.
!!! related TS1376 b.ts:1:18: 'a' was imported here.
import AA = b.A; // Error
~~~
!!! error TS1380: An import alias cannot reference a declaration that was imported using 'import type'.
!!! related TS1376 b.ts:1:18: 'a' was imported here.
Copy link
Member Author

Choose a reason for hiding this comment

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

An error was already reported on the declaration of A so this follow-on error isn't necessary.


import x = b.x;
console.log(x);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--- old.importEquals3.errors.txt
+++ new.importEquals3.errors.txt
@@= skipped -0, +0 lines =@@
b.ts(2,12): error TS1380: An import alias cannot reference a declaration that was imported using 'import type'.
b.ts(3,13): error TS1380: An import alias cannot reference a declaration that was imported using 'import type'.
c.ts(2,12): error TS1380: An import alias cannot reference a declaration that was imported using 'import type'.
-c.ts(3,13): error TS1380: An import alias cannot reference a declaration that was imported using 'import type'.


==== a.ts (0 errors) ====
@@= skipped -20, +19 lines =@@
const x = 0;
export { a, A, x };

-==== c.ts (2 errors) ====
+==== c.ts (1 errors) ====
import * as b from './b';
import A = b.a.A; // Error
~~~~~
!!! error TS1380: An import alias cannot reference a declaration that was imported using 'import type'.
!!! related TS1376 b.ts:1:18: 'a' was imported here.
import AA = b.A; // Error
- ~~~
-!!! error TS1380: An import alias cannot reference a declaration that was imported using 'import type'.
-!!! related TS1376 b.ts:1:18: 'a' was imported here.

import x = b.x;
console.log(x);
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
b.ts(1,10): error TS2440: Import declaration conflicts with local declaration of 'A'.
c.ts(2,1): error TS1362: 'A' cannot be used as a value because it was exported using 'export type'.
c.ts(3,1): error TS1362: 'A' cannot be used as a value because it was exported using 'export type'.
c.ts(4,1): error TS1362: 'A' cannot be used as a value because it was exported using 'export type'.
c.ts(4,1): error TS2349: This expression is not callable.
Type 'typeof A' has no call signatures.

Expand All @@ -19,21 +16,12 @@ c.ts(4,1): error TS2349: This expression is not callable.
}
export { A };

==== c.ts (4 errors) ====
==== c.ts (1 errors) ====
import { A } from "./b";
A;
~
!!! error TS1362: 'A' cannot be used as a value because it was exported using 'export type'.
!!! related TS1377 a.ts:2:15: 'A' was exported here.
A.displayName;
~
!!! error TS1362: 'A' cannot be used as a value because it was exported using 'export type'.
!!! related TS1377 a.ts:2:15: 'A' was exported here.
A();
~
!!! error TS1362: 'A' cannot be used as a value because it was exported using 'export type'.
!!! related TS1377 a.ts:2:15: 'A' was exported here.
~
Copy link
Member Author

Choose a reason for hiding this comment

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

These (previously inconsistently reported) errors are now no longer reported.

!!! error TS2349: This expression is not callable.
!!! error TS2349: Type 'typeof A' has no call signatures.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--- old.typeOnlyMerge3.errors.txt
+++ new.typeOnlyMerge3.errors.txt
@@= skipped -0, +0 lines =@@
b.ts(1,10): error TS2440: Import declaration conflicts with local declaration of 'A'.
-c.ts(2,1): error TS1362: 'A' cannot be used as a value because it was exported using 'export type'.
-c.ts(3,1): error TS1362: 'A' cannot be used as a value because it was exported using 'export type'.
-c.ts(4,1): error TS1362: 'A' cannot be used as a value because it was exported using 'export type'.
c.ts(4,1): error TS2349: This expression is not callable.
Type 'typeof A' has no call signatures.

@@= skipped -18, +15 lines =@@
}
export { A };

-==== c.ts (4 errors) ====
+==== c.ts (1 errors) ====
import { A } from "./b";
A;
- ~
-!!! error TS1362: 'A' cannot be used as a value because it was exported using 'export type'.
-!!! related TS1377 a.ts:2:15: 'A' was exported here.
A.displayName;
- ~
-!!! error TS1362: 'A' cannot be used as a value because it was exported using 'export type'.
-!!! related TS1377 a.ts:2:15: 'A' was exported here.
A();
- ~
-!!! error TS1362: 'A' cannot be used as a value because it was exported using 'export type'.
-!!! related TS1377 a.ts:2:15: 'A' was exported here.
~
!!! error TS2349: This expression is not callable.
!!! error TS2349: Type 'typeof A' has no call signatures.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var t = p.x;

=== node_modules/math2d/index.d.ts ===
export as namespace Math2d;
>Math2d : typeof import("node_modules/math2d/index.d.ts")
>Math2d : typeof import("node_modules/math2d/index")
Copy link
Member

Choose a reason for hiding this comment

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

Odd change; wonder where this is coming from...

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't know, suspect it comes from something in emit.


export = M2D;
>M2D : typeof import("node_modules/math2d/index.d.ts")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@

var t = p.x;
>t : number
@@= skipped -65, +65 lines =@@
@@= skipped -12, +12 lines =@@

=== node_modules/math2d/index.d.ts ===
export as namespace Math2d;
->Math2d : typeof import("node_modules/math2d/index.d.ts")
+>Math2d : typeof import("node_modules/math2d/index")

export = M2D;
>M2D : typeof import("node_modules/math2d/index.d.ts")
@@= skipped -53, +53 lines =@@
// Add a method to the class
interface Vector {
reverse(): Math2d.Point;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var t = p.x;

=== node_modules/math2d/index.d.ts ===
export as namespace Math2d;
>Math2d : typeof import("node_modules/math2d/index.d.ts")
>Math2d : typeof import("node_modules/math2d/index")

export = M2D;
>M2D : typeof import("node_modules/math2d/index.d.ts")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
--- old.umd-augmentation-4.types
+++ new.umd-augmentation-4.types
@@= skipped -98, +98 lines =@@
@@= skipped -45, +45 lines =@@

=== node_modules/math2d/index.d.ts ===
export as namespace Math2d;
->Math2d : typeof import("node_modules/math2d/index.d.ts")
+>Math2d : typeof import("node_modules/math2d/index")

export = M2D;
>M2D : typeof import("node_modules/math2d/index.d.ts")
@@= skipped -53, +53 lines =@@
// Add a method to the class
interface Vector {
reverse(): Math2d.Point;
Expand Down