2014-09-12 22:35:07 +02:00
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(27,16): error TS1005: ',' expected.
2014-12-04 17:53:45 +01:00
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(32,23): error TS1005: '(' expected.
2014-09-12 22:35:07 +02:00
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(37,9): error TS2350: Only a void function can be called with the 'new' keyword.
2014-12-04 17:53:45 +01:00
==== tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts (3 errors) ====
2014-07-13 01:04:16 +02:00
class C0 {
}
class C1 {
constructor(n: number, s: string) { }
}
class T<T> {
constructor(n?: T) { }
}
var anyCtor: {
new (): any;
};
var anyCtor1: {
new (n): any;
};
interface nestedCtor {
new (): nestedCtor;
}
var nestedCtor: nestedCtor;
// Construct expression with no parentheses for construct signature with > 0 parameters
var b = new C0 32, ''; // Parse error
~~
2014-09-12 00:19:57 +02:00
!!! error TS1005: ',' expected.
2014-07-13 01:04:16 +02:00
// Generic construct expression with no parentheses
var c1 = new T;
var c1: T<{}>;
var c2 = new T<string>; // Parse error
~
2014-12-04 17:53:45 +01:00
!!! error TS1005: '(' expected.
2014-07-13 01:04:16 +02:00
// Construct expression of non-void returning function
function fnNumber(): number { return 32; }
var s = new fnNumber(); // Error
~~~~~~~~~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2350: Only a void function can be called with the 'new' keyword.
2014-07-13 01:04:16 +02:00