Skip to content

Commit c9da705

Browse files
committed
Update tests
1. Accept baselines 2. Fix APISample_watcher 3. Switch checker to use JSDOc for isWeak Some of the baselines seem incorrect or weirder than before.
1 parent 2433f56 commit c9da705

15 files changed

+115
-995
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9392,8 +9392,10 @@ namespace ts {
93929392
return result;
93939393
}
93949394

9395-
// A type is 'weak' if it is an object type with at least one optional property
9396-
// and no required properties or index signatures
9395+
/**
9396+
* A type is 'weak' if it is an object type with at least one optional property
9397+
* and no required properties or index signatures
9398+
*/
93979399
function isWeak(type: Type) {
93989400
let props = getPropertiesOfType(type);
93999401
return type.flags & TypeFlags.Object &&

tests/baselines/reference/APISample_watcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ declare var fs: {
1111
existsSync(path: string): boolean;
1212
readdirSync(path: string): string[];
1313
readFileSync(filename: string, encoding?: string): string;
14-
writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
14+
writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; } | string): void;
1515
watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: { mtime: Date }, prev: { mtime: Date }) => void): void;
1616
};
1717
declare var path: any;

tests/baselines/reference/controlFlowInstanceof.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ function goo(x: X) {
247247

248248
x.y;
249249
>x.y : string
250-
>x : Y
250+
>x : X & Y
251251
>y : string
252252
}
253253
x;

tests/baselines/reference/generatorTypeCheck63.errors.txt

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,14): error TS2322: Type '(a: State | 1) => IterableIterator<State | 1>' is not assignable to type 'Strategy<State>'.
2-
Type 'IterableIterator<State | 1>' is not assignable to type 'IterableIterator<State>'.
3-
Type 'State | 1' is not assignable to type 'State'.
4-
Type '1' is not assignable to type 'State'.
1+
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(24,61): error TS2345: Argument of type '(state: State) => IterableIterator<State | 1>' is not assignable to parameter of type '(a: StrategicState) => IterableIterator<StrategicState>'.
2+
Type 'IterableIterator<State | 1>' is not assignable to type 'IterableIterator<StrategicState>'.
3+
Type 'State | 1' is not assignable to type 'StrategicState'.
4+
Type '1' is not assignable to type 'StrategicState'.
55
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(29,70): error TS7025: Generator implicitly has type 'IterableIterator<any>' because it does not yield any values. Consider supplying a return type.
66
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(32,42): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
77
Type argument candidate 'State' is not a valid type argument because it is not a supertype of candidate '1'.
8-
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(36,14): error TS2322: Type '(a: State | 1) => IterableIterator<State | 1>' is not assignable to type 'Strategy<State>'.
8+
tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(36,62): error TS2345: Argument of type '(state: State) => IterableIterator<State | 1>' is not assignable to parameter of type '(a: StrategicState) => IterableIterator<StrategicState>'.
9+
Type 'IterableIterator<State | 1>' is not assignable to type 'IterableIterator<StrategicState>'.
910

1011

1112
==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts (4 errors) ====
@@ -33,11 +34,11 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(36,14): err
3334
}
3435

3536
export const Nothing: Strategy<State> = strategy("Nothing", function* (state: State) {
36-
~~~~~~~
37-
!!! error TS2322: Type '(a: State | 1) => IterableIterator<State | 1>' is not assignable to type 'Strategy<State>'.
38-
!!! error TS2322: Type 'IterableIterator<State | 1>' is not assignable to type 'IterableIterator<State>'.
39-
!!! error TS2322: Type 'State | 1' is not assignable to type 'State'.
40-
!!! error TS2322: Type '1' is not assignable to type 'State'.
37+
~~~~~~~~
38+
!!! error TS2345: Argument of type '(state: State) => IterableIterator<State | 1>' is not assignable to parameter of type '(a: StrategicState) => IterableIterator<StrategicState>'.
39+
!!! error TS2345: Type 'IterableIterator<State | 1>' is not assignable to type 'IterableIterator<StrategicState>'.
40+
!!! error TS2345: Type 'State | 1' is not assignable to type 'StrategicState'.
41+
!!! error TS2345: Type '1' is not assignable to type 'StrategicState'.
4142
yield 1;
4243
return state;
4344
});
@@ -55,8 +56,9 @@ tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(36,14): err
5556
});
5657

5758
export const Nothing3: Strategy<State> = strategy("Nothing", function* (state: State) {
58-
~~~~~~~~
59-
!!! error TS2322: Type '(a: State | 1) => IterableIterator<State | 1>' is not assignable to type 'Strategy<State>'.
59+
~~~~~~~~
60+
!!! error TS2345: Argument of type '(state: State) => IterableIterator<State | 1>' is not assignable to parameter of type '(a: StrategicState) => IterableIterator<StrategicState>'.
61+
!!! error TS2345: Type 'IterableIterator<State | 1>' is not assignable to type 'IterableIterator<StrategicState>'.
6062
yield state;
6163
return 1;
6264
});

tests/baselines/reference/subtypingWithObjectMembersOptionality3.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ var b: { Foo2: Derived; }
6969
>Derived : Derived
7070

7171
var r = true ? a : b; // ok
72-
>r : { Foo?: Base; }
73-
>true ? a : b : { Foo?: Base; }
72+
>r : { Foo?: Base; } | { Foo2: Derived; }
73+
>true ? a : b : { Foo?: Base; } | { Foo2: Derived; }
7474
>true : true
7575
>a : { Foo?: Base; }
7676
>b : { Foo2: Derived; }

tests/baselines/reference/subtypingWithObjectMembersOptionality4.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ var b: { Foo2?: Derived; }
6969
>Derived : Derived
7070

7171
var r = true ? a : b; // ok
72-
>r : { Foo2?: Derived; }
73-
>true ? a : b : { Foo2?: Derived; }
72+
>r : { Foo: Base; } | { Foo2?: Derived; }
73+
>true ? a : b : { Foo: Base; } | { Foo2?: Derived; }
7474
>true : true
7575
>a : { Foo: Base; }
7676
>b : { Foo2?: Derived; }

tests/baselines/reference/tsxAttributeResolution1.errors.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
tests/cases/conformance/jsx/file.tsx(23,8): error TS2322: Type '{ x: "0"; }' is not assignable to type 'Attribs1'.
22
Types of property 'x' are incompatible.
33
Type '"0"' is not assignable to type 'number'.
4-
tests/cases/conformance/jsx/file.tsx(24,8): error TS2339: Property 'y' does not exist on type 'Attribs1'.
5-
tests/cases/conformance/jsx/file.tsx(25,8): error TS2339: Property 'y' does not exist on type 'Attribs1'.
4+
tests/cases/conformance/jsx/file.tsx(24,8): error TS2322: Type '{ y: 0; }' is not assignable to type 'Attribs1'.
5+
Weak type 'Attribs1' has no properties in common with '{ y: 0; }'.
6+
tests/cases/conformance/jsx/file.tsx(25,8): error TS2322: Type '{ y: "foo"; }' is not assignable to type 'Attribs1'.
7+
Weak type 'Attribs1' has no properties in common with '{ y: "foo"; }'.
68
tests/cases/conformance/jsx/file.tsx(26,8): error TS2322: Type '{ x: "32"; }' is not assignable to type 'Attribs1'.
79
Types of property 'x' are incompatible.
810
Type '"32"' is not assignable to type 'number'.
9-
tests/cases/conformance/jsx/file.tsx(27,8): error TS2339: Property 'var' does not exist on type 'Attribs1'.
11+
tests/cases/conformance/jsx/file.tsx(27,8): error TS2322: Type '{ var: "10"; }' is not assignable to type 'Attribs1'.
12+
Weak type 'Attribs1' has no properties in common with '{ var: "10"; }'.
1013
tests/cases/conformance/jsx/file.tsx(29,1): error TS2322: Type '{}' is not assignable to type '{ reqd: string; }'.
1114
Property 'reqd' is missing in type '{}'.
1215
tests/cases/conformance/jsx/file.tsx(30,8): error TS2322: Type '{ reqd: 10; }' is not assignable to type '{ reqd: string; }'.
@@ -44,18 +47,21 @@ tests/cases/conformance/jsx/file.tsx(30,8): error TS2322: Type '{ reqd: 10; }' i
4447
!!! error TS2322: Type '"0"' is not assignable to type 'number'.
4548
<test1 y={0} />; // Error, no property "y"
4649
~~~~~
47-
!!! error TS2339: Property 'y' does not exist on type 'Attribs1'.
50+
!!! error TS2322: Type '{ y: 0; }' is not assignable to type 'Attribs1'.
51+
!!! error TS2322: Weak type 'Attribs1' has no properties in common with '{ y: 0; }'.
4852
<test1 y="foo" />; // Error, no property "y"
4953
~~~~~~~
50-
!!! error TS2339: Property 'y' does not exist on type 'Attribs1'.
54+
!!! error TS2322: Type '{ y: "foo"; }' is not assignable to type 'Attribs1'.
55+
!!! error TS2322: Weak type 'Attribs1' has no properties in common with '{ y: "foo"; }'.
5156
<test1 x="32" />; // Error, "32" is not number
5257
~~~~~~
5358
!!! error TS2322: Type '{ x: "32"; }' is not assignable to type 'Attribs1'.
5459
!!! error TS2322: Types of property 'x' are incompatible.
5560
!!! error TS2322: Type '"32"' is not assignable to type 'number'.
5661
<test1 var="10" />; // Error, no 'var' property
5762
~~~~~~~~
58-
!!! error TS2339: Property 'var' does not exist on type 'Attribs1'.
63+
!!! error TS2322: Type '{ var: "10"; }' is not assignable to type 'Attribs1'.
64+
!!! error TS2322: Weak type 'Attribs1' has no properties in common with '{ var: "10"; }'.
5965

6066
<test2 />; // Error, missing reqd
6167
~~~~~~~~~

tests/baselines/reference/tsxAttributeResolution11.errors.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
tests/cases/conformance/jsx/file.tsx(11,22): error TS2339: Property 'bar' does not exist on type 'IntrinsicAttributes & { ref?: string; }'.
1+
tests/cases/conformance/jsx/file.tsx(11,22): error TS2322: Type '{ bar: "world"; }' is not assignable to type 'IntrinsicAttributes & { ref?: string; }'.
2+
Weak type 'IntrinsicAttributes & { ref?: string; }' has no properties in common with '{ bar: "world"; }'.
23

34

45
==== tests/cases/conformance/jsx/react.d.ts (0 errors) ====
@@ -27,6 +28,7 @@ tests/cases/conformance/jsx/file.tsx(11,22): error TS2339: Property 'bar' does n
2728
// Should be an OK
2829
var x = <MyComponent bar='world' />;
2930
~~~~~~~~~~~
30-
!!! error TS2339: Property 'bar' does not exist on type 'IntrinsicAttributes & { ref?: string; }'.
31+
!!! error TS2322: Type '{ bar: "world"; }' is not assignable to type 'IntrinsicAttributes & { ref?: string; }'.
32+
!!! error TS2322: Weak type 'IntrinsicAttributes & { ref?: string; }' has no properties in common with '{ bar: "world"; }'.
3133

3234

tests/baselines/reference/tsxElementResolution11.errors.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
tests/cases/conformance/jsx/file.tsx(17,7): error TS2339: Property 'x' does not exist on type '{ q?: number; }'.
1+
tests/cases/conformance/jsx/file.tsx(17,7): error TS2322: Type '{ x: 10; }' is not assignable to type '{ q?: number; }'.
2+
Weak type '{ q?: number; }' has no properties in common with '{ x: 10; }'.
23

34

45
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
@@ -20,7 +21,8 @@ tests/cases/conformance/jsx/file.tsx(17,7): error TS2339: Property 'x' does not
2021
var Obj2: Obj2type;
2122
<Obj2 x={10} />; // Error
2223
~~~~~~
23-
!!! error TS2339: Property 'x' does not exist on type '{ q?: number; }'.
24+
!!! error TS2322: Type '{ x: 10; }' is not assignable to type '{ q?: number; }'.
25+
!!! error TS2322: Weak type '{ q?: number; }' has no properties in common with '{ x: 10; }'.
2426

2527
interface Obj3type {
2628
new(n: string): { x: number; };

0 commit comments

Comments
 (0)