Files
tsgo/testdata/baselines/reference/submodule/conformance/instantiationExpressionErrors.errors.txt

155 lines
6.1 KiB
Plaintext

instantiationExpressionErrors.ts(7,13): error TS1477: An instantiation expression cannot be followed by a property access.
instantiationExpressionErrors.ts(8,13): error TS1477: An instantiation expression cannot be followed by a property access.
instantiationExpressionErrors.ts(13,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string[]'.
instantiationExpressionErrors.ts(13,14): error TS2693: 'number' only refers to a type, but is being used as a value here.
instantiationExpressionErrors.ts(18,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'.
instantiationExpressionErrors.ts(18,14): error TS2693: 'number' only refers to a type, but is being used as a value here.
instantiationExpressionErrors.ts(18,29): error TS1109: Expression expected.
instantiationExpressionErrors.ts(19,24): error TS2635: Type '{ (): number; g<U>(): U; }' has no signatures for which the type argument list is applicable.
instantiationExpressionErrors.ts(23,23): error TS1005: '(' expected.
instantiationExpressionErrors.ts(26,24): error TS2558: Expected 0 type arguments, but got 1.
instantiationExpressionErrors.ts(39,2): error TS2554: Expected 0 arguments, but got 1.
instantiationExpressionErrors.ts(43,12): error TS2365: Operator '<' cannot be applied to types '{ <T>(): T; g<U>(): U; }' and 'boolean'.
instantiationExpressionErrors.ts(44,12): error TS2365: Operator '<' cannot be applied to types '{ <T>(): T; g<U>(): U; }' and 'boolean'.
instantiationExpressionErrors.ts(44,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'.
instantiationExpressionErrors.ts(45,12): error TS2365: Operator '<' cannot be applied to types '{ <T>(): T; g<U>(): U; }' and 'boolean'.
instantiationExpressionErrors.ts(45,12): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'.
==== instantiationExpressionErrors.ts (16 errors) ====
declare let f: { <T>(): T, g<U>(): U };
// Type arguments in member expressions
const a1 = f<number>; // { (): number; g<U>(): U; }
const a2 = f.g<number>; // () => number
const a3 = f<number>.g; // <U>() => U
~~~~~~~~
!!! error TS1477: An instantiation expression cannot be followed by a property access.
const a4 = f<number>.g<number>; // () => number
~~~~~~~~
!!! error TS1477: An instantiation expression cannot be followed by a property access.
const a5 = f['g']<number>; // () => number
// `[` is an expression starter and cannot immediately follow a type argument list
const a6 = f<number>['g']; // Error
~~~~~~~~~~~~~~
!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'string[]'.
~~~~~~
!!! error TS2693: 'number' only refers to a type, but is being used as a value here.
const a7 = (f<number>)['g'];
// An `<` cannot immediately follow a type argument list
const a8 = f<number><number>; // Relational operator error
~~~~~~~~~~~~~~~~~
!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'.
~~~~~~
!!! error TS2693: 'number' only refers to a type, but is being used as a value here.
~
!!! error TS1109: Expression expected.
const a9 = (f<number>)<number>; // Error, no applicable signatures
~~~~~~
!!! error TS2635: Type '{ (): number; g<U>(): U; }' has no signatures for which the type argument list is applicable.
// Type arguments with `?.` token
const b1 = f?.<number>; // Error, `(` expected
~
!!! error TS1005: '(' expected.
const b2 = f?.<number>();
const b3 = f<number>?.();
const b4 = f<number>?.<number>(); // Error, expected no type arguments
~~~~~~
!!! error TS2558: Expected 0 type arguments, but got 1.
// Instantiation expression and binary operators
declare let g: (<T>(x: T) => T) | undefined;
const c1 = g<string> || ((x: string) => x);
const c2 = g<string> ?? ((x: string) => x);
const c3 = g<string> && ((x: string) => x);
// Parsed as function call, even though this differs from JavaScript
const x1 = f<true>
(true);
~~~~
!!! error TS2554: Expected 0 arguments, but got 1.
// Parsed as relational expressions
const r1 = f < true > true;
~~~~~~~~
!!! error TS2365: Operator '<' cannot be applied to types '{ <T>(): T; g<U>(): U; }' and 'boolean'.
const r2 = f < true > +1;
~~~~~~~~
!!! error TS2365: Operator '<' cannot be applied to types '{ <T>(): T; g<U>(): U; }' and 'boolean'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'.
const r3 = f < true > -1;
~~~~~~~~
!!! error TS2365: Operator '<' cannot be applied to types '{ <T>(): T; g<U>(): U; }' and 'boolean'.
~~~~~~~~~~~~~
!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'.
// All of the following are parsed as instantiation expressions
const x2 = f<true>
true;
const x3 = f<true>;
true;
const x4 = f<true>
if (true) {}
const x5 = f<true>
let yy = 0;
const x6 = f<true>
interface I {}
let x10 = f<true>
this.bar()
let x11 = f<true>
function bar() {}
let x12 = f<true>
class C {}
let x13 = f<true>
bar()
let x14 = f<true>
void bar()
class C1 {
static specialFoo = f<string>
static bar = 123
}
class C2 {
public specialFoo = f<string>
public bar = 123
}
class C3 {
private specialFoo = f<string>
private bar = 123
}
class C4 {
protected specialFoo = f<string>
protected bar = 123
}
// Repro from #49551
const enum MyVer { v1 = 1, v2 = 2 }
let ver = 21
const a = ver < (MyVer.v1 >= MyVer.v2 ? MyVer.v1 : MyVer.v2)