@@ -11,7 +11,6 @@ import (
1111 "github.com/microsoft/TypeScript/tsc/internal/checker"
1212 "github.com/microsoft/TypeScript/tsc/internal/compiler"
1313 "github.com/microsoft/TypeScript/tsc/internal/core"
14- "github.com/microsoft/TypeScript/tsc/internal/diagnostics"
1514 "github.com/microsoft/TypeScript/tsc/internal/repo"
1615 "github.com/microsoft/TypeScript/tsc/internal/tsoptions"
1716 "github.com/microsoft/TypeScript/tsc/internal/tspath"
@@ -63,32 +62,6 @@ foo.bar;`
6362 }
6463}
6564
66- func TestTypeArgumentConstraintDiagnosticWithHeadMessage (t * testing.T ) {
67- t .Parallel ()
68-
69- fs := bundled .WrapFS (vfstest .FromMap (map [string ]string {
70- "/foo.ts" : `declare function f<T extends U, U>(): void;
71- f<number, string>();` ,
72- "/tsconfig.json" : `{"files":["foo.ts"]}` ,
73- }, tspath .CaseInsensitive ))
74- host := compiler .NewCompilerHost (fs , bundled .LibPath (), nil , nil , nil )
75- parsed , errors := tsoptions .GetParsedCommandLineOfConfigFile ("/tsconfig.json" , & core.CompilerOptions {}, nil , tsoptions .NewDefaultParseConfigHost (fs ), nil )
76- assert .Equal (t , len (errors ), 0 )
77- p := compiler .NewProgram (compiler.ProgramOptions {Config : parsed , Host : host })
78- c , done := p .GetTypeChecker (t .Context ())
79- defer done ()
80- file := p .GetSourceFile ("/foo.ts" )
81- call := file .Statements .Nodes [1 ].Expression ()
82- signature := c .GetSignaturesOfType (c .GetTypeAtLocation (call .Expression ()), checker .SignatureKindCall )[0 ]
83- diags := c .CheckTypeArgumentsForTest (signature , call .TypeArguments (), diagnostics .Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression )
84- assert .Equal (t , len (diags ), 1 )
85- assert .Equal (t , diags [0 ].Code (), diagnostics .Type_0_does_not_satisfy_the_constraint_1 .Code ())
86- assert .DeepEqual (t , diags [0 ].MessageArgs (), []string {"number" , "string" })
87- assert .Assert (t , strings .Contains (diags [0 ].String (), "Type 'number' does not satisfy the constraint 'string'." ))
88- assert .Equal (t , len (diags [0 ].MessageChain ()), 1 )
89- assert .Equal (t , diags [0 ].MessageChain ()[0 ].Code (), diagnostics .Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression .Code ())
90- }
91-
9265func TestGetTypeAtLocationOfTypeOnlyImportClause (t * testing.T ) {
9366 t .Parallel ()
9467
0 commit comments