Commit graph

191 commits

Author SHA1 Message Date
Vladimir Matveev
bc02341e99 addressed PR feedback, updated tests to suppress reachability errors where they are not needed 2015-10-13 10:58:55 -07:00
Tingan Ho
dd54b7a36f Adds tests 2015-10-06 19:03:11 +08:00
Ryan Cavanaugh
b2797bbaab Correctly emit 'as' operator left operand as expression
Fixes #4832
2015-09-28 17:24:59 -07:00
Vladimir Matveev
68d6d8c550 use Harness.IO instead of sys in harness 2015-08-21 00:31:25 -07:00
Jason Freeman
8e5f34fb4b Add downlevel emit tests 2015-07-15 15:04:24 -07:00
Jason Freeman
75f97f302a Add tests 2015-07-15 14:42:17 -07:00
Ryan Cavanaugh
b3ca00986f Merge remote-tracking branch 'upstream/master' into jsxAndAs 2015-06-22 22:41:41 -07:00
Ryan Cavanaugh
2b44dcac4d Conformance tests for 'as' operator 2015-06-18 14:03:14 -07:00
Tingan Ho
752e0ba003 Fixes type predicate crash bug 2015-06-18 23:04:05 +08:00
Jason Freeman
75ed565f81 Don't consume 'is' keyword if there is a preceding line terminator 2015-06-09 11:12:00 -07:00
Tingan Ho
51a43dd9d5 Addresses CR feedback 2015-06-08 13:34:49 +08:00
Tingan Ho
b1a8a5fe66 Addresses CR feedback 2015-06-07 22:16:09 +08:00
Tingan Ho
487dff564f Fixes CR feedback 2015-06-06 13:59:19 +08:00
Tingan Ho
fa9a914648 Adds error for non-return positioned type predicates and changed parse type predicate logic 2015-06-05 16:36:02 +08:00
Tingan Ho
19e725636e Adds PR feedback and removed references to typeguard (class) methods 2015-06-04 19:31:16 +08:00
Tingan Ho
b7d1df68fb Adds type guard methods 2015-06-03 16:58:56 +08:00
Tingan Ho
f8e2b99b6c Adds tests 2015-06-03 16:58:56 +08:00
Tingan Ho
78a36c0cee Fixes concat style 2015-05-16 16:42:49 +08:00
Tingan Ho
629b4bbfdf Saved 2015-05-15 15:45:08 +08:00
Tingan Ho
a97ea4b657 Corrects old tests. 2015-05-15 08:38:44 +08:00
Tingan Ho
fdfbcf6ffc Adds tests 2015-05-15 08:38:43 +08:00
Mohamed Hegazy
8b43b3d18c Update test 2015-05-06 20:18:32 -07:00
Mohamed Hegazy
5e94ce65ed Merge branch 'typeguardsByConstructorSigniture' of https://github.com/vvakame/TypeScript into vvakame-typeguardsByConstructorSigniture 2015-05-06 12:44:45 -07:00
vvakame
776f390786 PR feedback 2015-05-06 21:18:15 +09:00
Yui
183c1c47ab Merge pull request #2753 from Microsoft/conformanceArrayLiteral
Conformance test for update in section 4.6 Array Literal
2015-05-04 10:50:41 -07:00
Yui
3da13152f0 Merge pull request #2761 from Microsoft/conformanceContextuallyTypedFuncExp
Conformance test for update spec section 4.9.3 contextual typing in function expression
2015-05-04 10:48:42 -07:00
Yui
031c344bd6 Merge pull request #2785 from Microsoft/conformanceTypeGuard
Conformance for spec update section 4.20 Add additional tests for typeguard for class or object property
2015-05-04 10:47:06 -07:00
vvakame
ab10d509f5 support instantiate signature, it has type parameters. 2015-05-02 15:27:06 +09:00
vvakame
35d6e98e98 type narrowing by constructor signiture of interface 2015-04-30 23:12:35 +09:00
Yui T
ac8ae27139 Address code review 2015-04-16 20:09:03 -07:00
Yui T
d94027b146 Add conformance tests for arugment expression, getSetAccessor, arrayLiteralExpression 2015-04-16 20:01:29 -07:00
Yui T
6d9c1f4c4a Add spec description into tests 2015-04-16 15:39:12 -07:00
Yui T
845b618b42 Add spec description to the test file and move tests that generate errors to separate file 2015-04-16 14:41:19 -07:00
Yui T
8899d5f056 Add additional tests for typeguard for class or object property 2015-04-15 16:55:59 -07:00
Yui T
496e23881b Change file name to be more consistent 2015-04-14 13:00:13 -07:00
Yui T
a689b9df38 Conformance test for update incontextual type in function expression 2015-04-14 10:26:47 -07:00
Yui T
d475170321 Conformance test for update in section 4.6 2015-04-13 16:16:04 -07:00
Ron Buckton
0546042df3 Add support for parsing destructuring patterns in arrow function parameter lists 2015-04-08 18:01:21 -07:00
Jason Freeman
f3543b718f In ES6, an Iterable should contextually type an array literal 2015-02-26 18:17:41 -08:00
Anders Hejlsberg
bbe51cfafe Adding tests 2015-02-04 15:39:57 -08:00
Anders Hejlsberg
34ed45df8e Adding more tests 2015-02-02 10:26:31 -08:00
Anders Hejlsberg
005676005f Adding test 2015-01-30 14:14:22 -08:00
Daniel Rosenwasser
e4d3051532 Added Jason's example for contextually typing parameters. 2015-01-27 22:39:48 -08:00
Daniel Rosenwasser
26929ee5f2 Merge pull request #1816 from Microsoft/typeArgsInSuperCall
Contextually type parameters in super calls using type arguments on the base class.
2015-01-27 17:29:48 -08:00
Daniel Rosenwasser
93dbcf006f Contextually type parameters in super calls using type arguments on the base class. 2015-01-26 18:42:17 -08:00
Anders Hejlsberg
0410394de0 Modifying test 2015-01-25 16:25:38 -08:00
Anders Hejlsberg
7f63180b64 Adding tests 2015-01-24 17:23:22 -08:00
Anders Hejlsberg
ccffc9f25f Adding more tests 2015-01-22 15:12:55 -08:00
Anders Hejlsberg
963de957cb Adding regression test 2015-01-22 14:52:15 -08:00
Anders Hejlsberg
f34620db63 Modifying and adding tests 2015-01-21 13:55:07 -08:00
Daniel Rosenwasser
bfe63cc4cb Merge pull request #1648 from Microsoft/contextualTypeParenthesizedExpressions
Contextually type parenthesized expressions
2015-01-14 14:52:07 -08:00
Yui T
fdadd3c18e Fix narrow type for instanceOf and add testcases 2015-01-14 11:30:58 -08:00
Anders Hejlsberg
59e266de02 Improved handing of union types in type guards 2015-01-12 14:51:20 -08:00
Daniel Rosenwasser
cd246992ed Clarified comment in test. 2015-01-09 14:19:24 -08:00
Daniel Rosenwasser
f5f4e28f4f Fixed portion of test. 2015-01-08 16:53:26 -08:00
Daniel Rosenwasser
d5f02813f0 Added tests for contextual typing on parenthesized expressions, added case for tagged templates. 2015-01-08 16:39:47 -08:00
Anders Hejlsberg
40dc1341ab Merge pull request #1621 from Microsoft/narrowingOfAny
Type guard narrows type any in a primitive type check
2015-01-08 15:57:15 -08:00
Anders Hejlsberg
968a56924f Type guard narrows type any in a primitive type check 2015-01-08 14:27:39 -08:00
Daniel Rosenwasser
1f6cd941fd Changed tests to error when actual contextual typing is broken. 2014-12-15 17:09:56 -08:00
Daniel Rosenwasser
0263d60071 Split contextual typing test for substitution expressions into two tests. 2014-12-15 16:14:35 -08:00
Daniel Rosenwasser
b65a422c7a Fixed contextual typing for tagged template expressions. 2014-12-15 14:11:21 -08:00
Anders Hejlsberg
35adeb8363 Addressing CR feedback 2014-12-10 14:44:31 -08:00
Anders Hejlsberg
98c9f75e21 Adding test case 2014-12-10 14:41:37 -08:00
Anders Hejlsberg
2876ba6a6c Addressing CR feedback 2014-12-10 14:25:02 -08:00
Anders Hejlsberg
37b5c74b93 Adding test case 2014-12-10 10:17:48 -08:00
Sheetal Nandi
ab4ccb3a1c Merge branch 'master' into unionTypeConformance 2014-11-21 01:33:13 -08:00
Anders Hejlsberg
df544a687c Addressing CR feedback 2014-11-14 13:36:09 -08:00
Anders Hejlsberg
91b97009f0 Modifying tests and accepting new baselines 2014-11-14 10:42:31 -08:00
Sheetal Nandi
152c77cd2a Add test cases for typeof x == s and typeof x != s form of typeguard which has no effect on narrowing type 2014-11-12 12:49:29 -08:00
Sheetal Nandi
45ca9d285f Add test case for instance of type guard with interface with prototype property 2014-11-12 12:36:06 -08:00
Sheetal Nandi
52a8560298 Typeguards of form !expr
•	A type guard of the form !expr
o	when true, narrows the type of x by expr when false, or
o	when false, narrows the type of x by expr when true.
2014-11-06 13:04:43 -08:00
Sheetal Nandi
c9a03dc659 Typeguards of form expr1 || expr2
•	A type guard of the form expr1 || expr2
o	when true, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when true, and T2 is the type of x narrowed by expr1 when false and then by expr2 when true, or
o	when false, narrows the type of x by expr1 when false and then by expr2 when false.
2014-11-06 13:04:40 -08:00
Sheetal Nandi
486d37ec90 TypeGuard of for expr1 && expr2
•	A type guard of the form expr1 && expr2
o	when true, narrows the type of x by expr1 when true and then by expr2 when true, or
o	when false, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when false, and T2 is the type of x narrowed by expr1 when true and then by expr2 when false.
2014-11-06 13:04:37 -08:00
Sheetal Nandi
7ebf5371a5 Test cases for typeguards of form typeof x === s and typeof x !== s
•	A type guard of the form typeof x === s, where s is a string literal with the value ‘string’, ‘number’, or ‘boolean’,
o	when true, narrows the type of x to the given primitive type, or
o	when false, removes the primitive type from the type of x.
•	A type guard of the form typeof x === s, where s is a string literal with any value but ‘string’, ‘number’, or ‘boolean’,
o	when true, removes the primitive types string, number, and boolean from the type of x, or
o	when false, has no effect on the type of x.
•	A type guard of the form typeof x !== s, where s is a string literal,
o	when true, narrows the type of x by typeof x === s when false, or
o	when false, narrows the type of x by typeof x === s when true.
2014-11-06 13:04:34 -08:00
Sheetal Nandi
5961ed7154 Test typeguard of form instance of
•	A type guard of the form x instanceof C, where C is of a subtype of the global type ‘Function’ and C has a property named ‘prototype’
o	when true, narrows the type of x to the type of the ‘prototype’ property in C provided it is a subtype of the type of x, or
o	when false, has no effect on the type of x.
2014-11-06 13:04:30 -08:00
Sheetal Nandi
2fecc132ab Tests for typeguards allowed on variables and parameters only
From spec:
Note that type guards affect types of variables and parameters only and have no effect on members of objects such as properties
2014-11-06 13:04:27 -08:00
Sheetal Nandi
33cdc2f876 Type guards in || operator
•	In the right operand of a || operation, the type of a variable or parameter is narrowed by any type guard in the left operand when false, provided the right operand contains no assignments to the variable or parameter.
2014-11-06 13:04:24 -08:00
Sheetal Nandi
11912e8fde TypeGuards in right operand of && operation
•	In the right operand of a && operation, the type of a variable or parameter is narrowed by any type guard in the left operand when true, provided the right operand contains no assignments to the variable or parameter.
2014-11-06 13:04:21 -08:00
Sheetal Nandi
55952af304 Tests for conditional expression typeguards
•	In the true expression of a conditional expression, the type of a variable or parameter is narrowed by any type guard in the condition when true, provided the expression contains no assignments to the variable or parameter.
•	In the false expression of a conditional expression, the type of a variable or parameter is narrowed by any type guard in the condition when false, provided the expression contains no assignments to the variable or parameter.
2014-11-06 13:04:18 -08:00
Sheetal Nandi
4b3d603f24 Test cases for typeguards are scoped at function /module block 2014-11-06 13:04:14 -08:00
Sheetal Nandi
2088a89223 Test cases to make sure typeguard is defeated in case of function calls
From spec:
Also note that it is possible to defeat a type guard by calling a function that changes the type of the guarded variable.
2014-11-06 13:04:11 -08:00
Sheetal Nandi
e79bec5cbf TypeGuards narrow types in if statement works per spec:
The type of a variable or parameter is narrowed in the following situations:
•	In the true branch statement of an ‘if’ statement, the type of a variable or parameter is narrowed by any type guard in the ‘if’ condition when true, provided the if statement contains no assignments to the variable or parameter.
•	In the false branch statement of an ‘if’ statement, the type of a variable or parameter is narrowed by any type guard in the ‘if’ condition when false, provided the if statement contains no assignments to the variable or parameter.
2014-11-06 13:04:08 -08:00
Sheetal Nandi
24ebc750c0 Tests for Conditional operator can generate union type 2014-11-04 13:18:43 -08:00
Sheetal Nandi
b66cd9b0fc Results of || operation produces union type 2014-11-04 13:18:40 -08:00
Anders Hejlsberg
10a7e6ba70 Fixing in, for...in, and instanceof with union type operands 2014-10-22 16:57:43 -07:00
Anders Hejlsberg
fc842b177e Merge branch 'master' into unionTypes
Conflicts:
	src/compiler/checker.ts
	src/compiler/types.ts
	src/services/services.ts
	tests/baselines/reference/assignmentCompatBetweenTupleAndArray.errors.txt
	tests/baselines/reference/bestCommonTypeOfTuple.types
	tests/baselines/reference/bestCommonTypeOfTuple2.types
	tests/baselines/reference/castingTuple.errors.txt
	tests/baselines/reference/contextualTypeWithTuple.errors.txt
	tests/baselines/reference/genericCallWithTupleType.errors.txt
	tests/baselines/reference/indexerWithTuple.types
	tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.errors.txt
2014-10-13 12:37:34 -07:00
Dan Quirk
bacb9d0b22 Test updates from union changes 2014-10-10 14:41:14 -07:00
ChrisBubernak
15c5c77704 Fixing tests and baselines 2014-10-08 11:11:36 -07:00
Chris Bubernak
c77135d3d9 Removed Numeric members from a bunch of tests
-in these tests it wasn't really in the spirit of the tests for them to be there
-also removed a test that no longer made sense
2014-10-06 16:14:45 -07:00
Jason Freeman
6fb3c34681 Conformance coverage for spec change #589 2014-09-05 18:44:49 -07:00
Mohamed Hegazy
214df64e28 Add snapshot of compiler sources 2014-07-12 17:30:19 -07:00