2017-04-08 17:52:38 +03:00
|
|
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
exports[`test.js - flow-verify 1`] = `
|
2017-04-12 23:41:51 +03:00
|
|
|
/* @noflow */
|
2017-04-08 17:52:38 +03:00
|
|
|
|
|
|
|
interface IFoo { foo: string }
|
|
|
|
|
|
|
|
class C1 implements IFoo {} // error: property \`foo\` not found
|
|
|
|
class C2 implements IFoo { foo: number } // error: number <~> string
|
|
|
|
class C3 implements IFoo { foo: string } // ok
|
|
|
|
|
|
|
|
(new C1: IFoo); // ok, we already errored at def site
|
|
|
|
|
|
|
|
interface IBar { bar: number }
|
|
|
|
|
|
|
|
class C4 implements IFoo, IBar {} // error: properties \`foo\`, \`bar\` not found
|
|
|
|
(new C4: IBar); // ok, we already errored at def site
|
|
|
|
|
|
|
|
interface IFooBar extends IFoo { bar: number }
|
|
|
|
|
|
|
|
class C5 implements IFooBar {} // error: properties \`foo\`, \`bar\` not found
|
|
|
|
(new C5: IFooBar); // ok, already errored at def site
|
|
|
|
(new C5: IFoo); // ok, already errored at def site
|
|
|
|
(new C5: IBar); // error: property \`bar\` not found (despite IBar < IFooBar)
|
|
|
|
|
|
|
|
class C6 extends C1 {}
|
|
|
|
(new C6: IFoo); // ok, C1 implements IFoo
|
|
|
|
|
|
|
|
class C7 implements C1 {} // error: C1 is a class, expected an interface
|
|
|
|
|
|
|
|
// ensure BoundT substituted appropriately
|
|
|
|
interface IPoly<T> { x: T }
|
|
|
|
class C8<T> implements IPoly<T> { x: T }
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
/* @noflow */
|
|
|
|
|
2018-11-10 19:15:18 +03:00
|
|
|
interface IFoo {
|
|
|
|
foo: string;
|
|
|
|
}
|
2017-04-08 17:52:38 +03:00
|
|
|
|
|
|
|
class C1 implements IFoo {} // error: property \`foo\` not found
|
|
|
|
class C2 implements IFoo {
|
|
|
|
foo: number;
|
|
|
|
} // error: number <~> string
|
|
|
|
class C3 implements IFoo {
|
|
|
|
foo: string;
|
|
|
|
} // ok
|
|
|
|
|
|
|
|
(new C1(): IFoo); // ok, we already errored at def site
|
|
|
|
|
2018-11-10 19:15:18 +03:00
|
|
|
interface IBar {
|
|
|
|
bar: number;
|
|
|
|
}
|
2017-04-08 17:52:38 +03:00
|
|
|
|
|
|
|
class C4 implements IFoo, IBar {} // error: properties \`foo\`, \`bar\` not found
|
|
|
|
(new C4(): IBar); // ok, we already errored at def site
|
|
|
|
|
2018-11-10 19:15:18 +03:00
|
|
|
interface IFooBar extends IFoo {
|
|
|
|
bar: number;
|
|
|
|
}
|
2017-04-08 17:52:38 +03:00
|
|
|
|
|
|
|
class C5 implements IFooBar {} // error: properties \`foo\`, \`bar\` not found
|
|
|
|
(new C5(): IFooBar); // ok, already errored at def site
|
|
|
|
(new C5(): IFoo); // ok, already errored at def site
|
|
|
|
(new C5(): IBar); // error: property \`bar\` not found (despite IBar < IFooBar)
|
|
|
|
|
|
|
|
class C6 extends C1 {}
|
|
|
|
(new C6(): IFoo); // ok, C1 implements IFoo
|
|
|
|
|
|
|
|
class C7 implements C1 {} // error: C1 is a class, expected an interface
|
|
|
|
|
|
|
|
// ensure BoundT substituted appropriately
|
2018-11-10 19:15:18 +03:00
|
|
|
interface IPoly<T> {
|
|
|
|
x: T;
|
|
|
|
}
|
2017-04-08 17:52:38 +03:00
|
|
|
class C8<T> implements IPoly<T> {
|
|
|
|
x: T;
|
|
|
|
}
|
2017-04-12 23:41:51 +03:00
|
|
|
|
2017-04-08 17:52:38 +03:00
|
|
|
`;
|