-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathtest-types.ts
47 lines (39 loc) · 1.51 KB
/
test-types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// This file exists only so that we can run the TypeScript compiler in the CI build
// to validate our typings.d.ts file.
import * as ld from 'launchdarkly-js-sdk-common';
var ver: string = ld.version;
var logger: ld.LDLogger = ld.createConsoleLogger("info");
var userWithKeyOnly: ld.LDUser = { key: 'user' };
var anonUserWithNoKey: ld.LDUser = { anonymous: true };
var user: ld.LDUser = {
key: 'user',
secondary: 'otherkey',
name: 'name',
firstName: 'first',
lastName: 'last',
email: '[email protected]',
avatar: 'http://avatar.url',
ip: '1.1.1.1',
country: 'us',
anonymous: true,
custom: {
'a': 's',
'b': true,
'c': 3,
'd': [ 'x', 'y' ],
'e': [ true, false ],
'f': [ 1, 2 ]
},
privateAttributeNames: [ 'name', 'email' ]
};
var client: ld.LDClientBase = {} as ld.LDClientBase; // wouldn't do this in real life, it's just so the following statements will compile
var boolFlagValue: ld.LDFlagValue = client.variation('key', false);
var numberFlagValue: ld.LDFlagValue = client.variation('key', 2);
var stringFlagValue: ld.LDFlagValue = client.variation('key', 'default');
var jsonFlagValue: ld.LDFlagValue = client.variation('key', [ 'a', 'b' ]);
var detail: ld.LDEvaluationDetail = client.variationDetail('key', 'default');
var detailValue: ld.LDFlagValue = detail.value;
var detailIndex: number | undefined = detail.variationIndex;
var detailReason: ld.LDEvaluationReason = detail.reason;
var flagSet: ld.LDFlagSet = client.allFlags();
var flagSetValue: ld.LDFlagValue = flagSet['key'];