Add tests
This commit is contained in:
parent
f58e1a2b17
commit
6cd7454a9b
2 changed files with 30 additions and 1 deletions
|
@ -125,3 +125,9 @@ c.setState({ });
|
|||
c.setState(foo);
|
||||
c.setState({ a: undefined }); // Error
|
||||
c.setState({ c: true }); // Error
|
||||
|
||||
type T2 = { a?: number, [key: string]: any };
|
||||
|
||||
let x1: T2 = { a: 'no' }; // Error
|
||||
let x2: Partial<T2> = { a: 'no' }; // Error
|
||||
let x3: { [P in keyof T2]: T2[P]} = { a: 'no' }; // Error
|
|
@ -1,4 +1,5 @@
|
|||
// @strictNullChecks: true
|
||||
// @noimplicitany: true
|
||||
|
||||
type T = { a: number, b: string };
|
||||
type TP = { a?: number, b?: string };
|
||||
|
@ -75,3 +76,25 @@ var b04: Partial<Readonly<B>>;
|
|||
var b04: Readonly<Partial<B>>;
|
||||
var b04: { [P in keyof BPR]: BPR[P] }
|
||||
var b04: Pick<BPR, keyof BPR>;
|
||||
|
||||
type Foo = { prop: number, [x: string]: number };
|
||||
|
||||
function f1(x: Partial<Foo>) {
|
||||
x.prop; // ok
|
||||
(x["other"] || 0).toFixed();
|
||||
}
|
||||
|
||||
function f2(x: Readonly<Foo>) {
|
||||
x.prop; // ok
|
||||
x["other"].toFixed();
|
||||
}
|
||||
|
||||
function f3(x: Boxified<Foo>) {
|
||||
x.prop; // ok
|
||||
x["other"].x.toFixed();
|
||||
}
|
||||
|
||||
function f4(x: { [P in keyof Foo]: Foo[P] }) {
|
||||
x.prop; // ok
|
||||
x["other"].toFixed();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue