mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Adding a few more tests
This commit is contained in:
parent
529fcfd4c9
commit
c623e6cc64
14
tests/baselines/reference/contextualIntersectionType.js
Normal file
14
tests/baselines/reference/contextualIntersectionType.js
Normal file
@ -0,0 +1,14 @@
|
||||
//// [contextualIntersectionType.ts]
|
||||
var x: { a: (s: string) => string } & { b: (n: number) => number };
|
||||
x = {
|
||||
a: s => s,
|
||||
b: n => n
|
||||
};
|
||||
|
||||
|
||||
//// [contextualIntersectionType.js]
|
||||
var x;
|
||||
x = {
|
||||
a: function (s) { return s; },
|
||||
b: function (n) { return n; }
|
||||
};
|
||||
23
tests/baselines/reference/contextualIntersectionType.symbols
Normal file
23
tests/baselines/reference/contextualIntersectionType.symbols
Normal file
@ -0,0 +1,23 @@
|
||||
=== tests/cases/conformance/types/intersection/contextualIntersectionType.ts ===
|
||||
var x: { a: (s: string) => string } & { b: (n: number) => number };
|
||||
>x : Symbol(x, Decl(contextualIntersectionType.ts, 0, 3))
|
||||
>a : Symbol(a, Decl(contextualIntersectionType.ts, 0, 8))
|
||||
>s : Symbol(s, Decl(contextualIntersectionType.ts, 0, 13))
|
||||
>b : Symbol(b, Decl(contextualIntersectionType.ts, 0, 39))
|
||||
>n : Symbol(n, Decl(contextualIntersectionType.ts, 0, 44))
|
||||
|
||||
x = {
|
||||
>x : Symbol(x, Decl(contextualIntersectionType.ts, 0, 3))
|
||||
|
||||
a: s => s,
|
||||
>a : Symbol(a, Decl(contextualIntersectionType.ts, 1, 5))
|
||||
>s : Symbol(s, Decl(contextualIntersectionType.ts, 2, 6))
|
||||
>s : Symbol(s, Decl(contextualIntersectionType.ts, 2, 6))
|
||||
|
||||
b: n => n
|
||||
>b : Symbol(b, Decl(contextualIntersectionType.ts, 2, 14))
|
||||
>n : Symbol(n, Decl(contextualIntersectionType.ts, 3, 6))
|
||||
>n : Symbol(n, Decl(contextualIntersectionType.ts, 3, 6))
|
||||
|
||||
};
|
||||
|
||||
27
tests/baselines/reference/contextualIntersectionType.types
Normal file
27
tests/baselines/reference/contextualIntersectionType.types
Normal file
@ -0,0 +1,27 @@
|
||||
=== tests/cases/conformance/types/intersection/contextualIntersectionType.ts ===
|
||||
var x: { a: (s: string) => string } & { b: (n: number) => number };
|
||||
>x : { a: (s: string) => string; } & { b: (n: number) => number; }
|
||||
>a : (s: string) => string
|
||||
>s : string
|
||||
>b : (n: number) => number
|
||||
>n : number
|
||||
|
||||
x = {
|
||||
>x = { a: s => s, b: n => n} : { a: (s: string) => string; b: (n: number) => number; }
|
||||
>x : { a: (s: string) => string; } & { b: (n: number) => number; }
|
||||
>{ a: s => s, b: n => n} : { a: (s: string) => string; b: (n: number) => number; }
|
||||
|
||||
a: s => s,
|
||||
>a : (s: string) => string
|
||||
>s => s : (s: string) => string
|
||||
>s : string
|
||||
>s : string
|
||||
|
||||
b: n => n
|
||||
>b : (n: number) => number
|
||||
>n => n : (n: number) => number
|
||||
>n : number
|
||||
>n : number
|
||||
|
||||
};
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(8,1): error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; b: string; }'.
|
||||
Property 'b' is missing in type '{ a: string; }'.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(9,1): error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; } & { b: string; }'.
|
||||
Type '{ a: string; }' is not assignable to type '{ b: string; }'.
|
||||
Property 'b' is missing in type '{ a: string; }'.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(13,1): error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; b: string; }'.
|
||||
Property 'a' is missing in type '{ b: string; }'.
|
||||
tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts(14,1): error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; } & { b: string; }'.
|
||||
Type '{ b: string; }' is not assignable to type '{ a: string; }'.
|
||||
Property 'a' is missing in type '{ b: string; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/intersection/intersectionTypeAssignment.ts (4 errors) ====
|
||||
var a: { a: string };
|
||||
var b: { b: string };
|
||||
var x: { a: string, b: string };
|
||||
var y: { a: string } & { b: string };
|
||||
|
||||
a = x;
|
||||
a = y;
|
||||
x = a; // Error
|
||||
~
|
||||
!!! error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; b: string; }'.
|
||||
!!! error TS2322: Property 'b' is missing in type '{ a: string; }'.
|
||||
y = a; // Error
|
||||
~
|
||||
!!! error TS2322: Type '{ a: string; }' is not assignable to type '{ a: string; } & { b: string; }'.
|
||||
!!! error TS2322: Type '{ a: string; }' is not assignable to type '{ b: string; }'.
|
||||
!!! error TS2322: Property 'b' is missing in type '{ a: string; }'.
|
||||
|
||||
b = x;
|
||||
b = y;
|
||||
x = b; // Error
|
||||
~
|
||||
!!! error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; b: string; }'.
|
||||
!!! error TS2322: Property 'a' is missing in type '{ b: string; }'.
|
||||
y = b; // Error
|
||||
~
|
||||
!!! error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; } & { b: string; }'.
|
||||
!!! error TS2322: Type '{ b: string; }' is not assignable to type '{ a: string; }'.
|
||||
!!! error TS2322: Property 'a' is missing in type '{ b: string; }'.
|
||||
|
||||
x = y;
|
||||
y = x;
|
||||
|
||||
35
tests/baselines/reference/intersectionTypeAssignment.js
Normal file
35
tests/baselines/reference/intersectionTypeAssignment.js
Normal file
@ -0,0 +1,35 @@
|
||||
//// [intersectionTypeAssignment.ts]
|
||||
var a: { a: string };
|
||||
var b: { b: string };
|
||||
var x: { a: string, b: string };
|
||||
var y: { a: string } & { b: string };
|
||||
|
||||
a = x;
|
||||
a = y;
|
||||
x = a; // Error
|
||||
y = a; // Error
|
||||
|
||||
b = x;
|
||||
b = y;
|
||||
x = b; // Error
|
||||
y = b; // Error
|
||||
|
||||
x = y;
|
||||
y = x;
|
||||
|
||||
|
||||
//// [intersectionTypeAssignment.js]
|
||||
var a;
|
||||
var b;
|
||||
var x;
|
||||
var y;
|
||||
a = x;
|
||||
a = y;
|
||||
x = a; // Error
|
||||
y = a; // Error
|
||||
b = x;
|
||||
b = y;
|
||||
x = b; // Error
|
||||
y = b; // Error
|
||||
x = y;
|
||||
y = x;
|
||||
@ -0,0 +1,5 @@
|
||||
var x: { a: (s: string) => string } & { b: (n: number) => number };
|
||||
x = {
|
||||
a: s => s,
|
||||
b: n => n
|
||||
};
|
||||
@ -0,0 +1,17 @@
|
||||
var a: { a: string };
|
||||
var b: { b: string };
|
||||
var x: { a: string, b: string };
|
||||
var y: { a: string } & { b: string };
|
||||
|
||||
a = x;
|
||||
a = y;
|
||||
x = a; // Error
|
||||
y = a; // Error
|
||||
|
||||
b = x;
|
||||
b = y;
|
||||
x = b; // Error
|
||||
y = b; // Error
|
||||
|
||||
x = y;
|
||||
y = x;
|
||||
Loading…
x
Reference in New Issue
Block a user