2014-11-29 23:51:25 +01:00
|
|
|
tests/cases/compiler/newOperator.ts(18,20): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead.
|
|
|
|
tests/cases/compiler/newOperator.ts(22,1): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead.
|
2014-11-20 22:48:23 +01:00
|
|
|
tests/cases/compiler/newOperator.ts(44,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
2014-09-12 22:35:07 +02:00
|
|
|
tests/cases/compiler/newOperator.ts(3,13): error TS2304: Cannot find name 'ifc'.
|
|
|
|
tests/cases/compiler/newOperator.ts(10,10): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
|
|
|
tests/cases/compiler/newOperator.ts(11,10): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
|
|
|
tests/cases/compiler/newOperator.ts(12,5): error TS2304: Cannot find name 'string'.
|
|
|
|
tests/cases/compiler/newOperator.ts(18,14): error TS2304: Cannot find name 'string'.
|
|
|
|
tests/cases/compiler/newOperator.ts(21,1): error TS2304: Cannot find name 'string'.
|
|
|
|
tests/cases/compiler/newOperator.ts(28,13): error TS2304: Cannot find name 'q'.
|
|
|
|
tests/cases/compiler/newOperator.ts(31,10): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
|
|
|
|
|
|
|
|
2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/compiler/newOperator.ts (11 errors) ====
|
|
|
|
interface ifc { }
|
|
|
|
// Attempting to 'new' an interface yields poor error
|
|
|
|
var i = new ifc();
|
|
|
|
~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2304: Cannot find name 'ifc'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
// Parens are optional
|
|
|
|
var x = new Date;
|
|
|
|
var y = new Date();
|
|
|
|
|
|
|
|
// Target is not a class or var, good error
|
|
|
|
var t1 = new 53();
|
|
|
|
~~~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
2014-07-13 01:04:16 +02:00
|
|
|
var t2 = new ''();
|
|
|
|
~~~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
2014-07-13 01:04:16 +02:00
|
|
|
new string;
|
|
|
|
~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2304: Cannot find name 'string'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
// Use in LHS of expression?
|
|
|
|
(new Date()).toString();
|
|
|
|
|
|
|
|
// Various spacing
|
|
|
|
var t3 = new string[]( );
|
2014-11-29 23:51:25 +01:00
|
|
|
~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead.
|
2014-07-13 01:04:16 +02:00
|
|
|
~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2304: Cannot find name 'string'.
|
2014-07-13 01:04:16 +02:00
|
|
|
var t4 =
|
|
|
|
new
|
|
|
|
string
|
|
|
|
~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2304: Cannot find name 'string'.
|
2014-07-13 01:04:16 +02:00
|
|
|
[
|
|
|
|
~
|
|
|
|
]
|
|
|
|
~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead.
|
2014-07-13 01:04:16 +02:00
|
|
|
(
|
|
|
|
);
|
|
|
|
|
|
|
|
// Unresolved symbol
|
|
|
|
var f = new q();
|
|
|
|
~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2304: Cannot find name 'q'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
// not legal
|
|
|
|
var t5 = new new Date;
|
|
|
|
~~~~~~~~~~~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
// Can be an expression
|
|
|
|
new String;
|
|
|
|
|
|
|
|
|
|
|
|
module M {
|
|
|
|
export class T {
|
|
|
|
x: number;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class S {
|
|
|
|
public get xs(): M.T[] {
|
2014-11-20 22:48:23 +01:00
|
|
|
~~
|
|
|
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
2014-07-13 01:04:16 +02:00
|
|
|
return new M.T[];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|