Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5ae8a81
WIP: fallback client
Jun 5, 2020
33af06f
Merge branch 'master' into fallback-client
Jun 10, 2020
6b349ec
Undo fallback client changes
Jun 10, 2020
3586598
Remove test investigation list
Jun 10, 2020
1d809a4
Restore unrelated rollup config changes
Jun 10, 2020
8ebe2b5
Remove unrelated eslint change
Jun 10, 2020
955a651
WIP: unit test support for typescript
Jun 10, 2020
77e65ec
Use version of mocha types compatible with our version of mocha
Jun 11, 2020
cfa3415
Consolidate to a single test command, remove esm, set allowJs: true i…
Jun 11, 2020
4d3d6bd
Sync exclude/include between rollup and tsconfig. Disable declaration…
Jun 11, 2020
6fd888e
Enable sourcemaps in tsconfig
Jun 11, 2020
19a1f5c
Foo test example for TS
Jun 11, 2020
68954e2
Update lint implementation for TypeScript
Jun 11, 2020
91797a6
Undo unrelated
Jun 11, 2020
9b2d7e0
Merge branch 'master' into mcarroll/optimizely-sdk-typescript
Jun 16, 2020
5f78cca
Remove duplicate entries in exclude arrays
Jun 16, 2020
b230942
Mention Jira number in index.d.ts TODOs
Jun 16, 2020
8dd1005
Convert string_value_validator module to TS
Jun 16, 2020
1923e00
Add ts-loader to karma + webpack configuration, enabling karma tests …
Jun 17, 2020
e1976ef
Merge branch 'master' into mcarroll/optimizely-sdk-typescript
Jul 14, 2020
fd1c2dc
Convert user_profile_service_validator module to TS (#526)
yavorona Jul 20, 2020
27288b3
feat: Convert event_tags_validator module to TS (#528)
yavorona Jul 29, 2020
de4e5b1
feat: Convert project_config_schema and json_schema_validator modules…
yavorona Jul 30, 2020
32839f4
feat: Convert attributes_validator to TS (#530)
yavorona Jul 30, 2020
ca0a3bc
fix(json schema validator): Replace empty object type assertion with …
mjc1283 Jul 30, 2020
8fad931
Fix configured entry point for json schema validator bundle
Jul 30, 2020
b9a4210
feat: Convert event_tag_utils module to TS (#544)
yavorona Jul 30, 2020
8b55526
Merge branch 'master' into mcarroll/optimizely-sdk-typescript
Jul 31, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion packages/optimizely-sdk/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ module.exports = {
commonjs: true,
node: true,
},
extends: 'eslint:recommended',
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
Expand All @@ -14,7 +17,18 @@ module.exports = {
ecmaVersion: 6,
sourceType: 'module',
},
overrides: [
{
'files': ['*.ts'],
'rules': {
'@typescript-eslint/explicit-module-boundary-types': ['error']
}
}
],
rules: {
'no-prototype-builtins': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'no-shadow': 'error',
},
};
12 changes: 12 additions & 0 deletions packages/optimizely-sdk/karma.base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ module.exports = {

webpack: {
mode: 'production',
module: {
rules: [
{
test: /\.[tj]s$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.ts', '.js'],
},
},

//browserStack setup
Expand Down
2 changes: 1 addition & 1 deletion packages/optimizely-sdk/lib/core/decision_service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import enums from '../../utils/enums';
import fns from '../../utils/fns';
import projectConfig from '../project_config';
import AudienceEvaluator from '../audience_evaluator';
import stringValidator from '../../utils/string_value_validator';
import * as stringValidator from '../../utils/string_value_validator';

var MODULE_NAME = 'DECISION_SERVICE';
var ERROR_MESSAGES = enums.ERROR_MESSAGES;
Expand Down
10 changes: 10 additions & 0 deletions packages/optimizely-sdk/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ declare module '@optimizely/optimizely-sdk' {

// The options object given to Optimizely.createInstance.
export interface Config {
// TODO[OASIS-6649]: Don't use object type
// eslint-disable-next-line @typescript-eslint/ban-types
datafile?: object | string;
datafileOptions?: DatafileOptions;
errorHandler?: ErrorHandler;
Expand All @@ -50,6 +52,8 @@ declare module '@optimizely/optimizely-sdk' {
| enums.LOG_LEVEL.INFO
| enums.LOG_LEVEL.NOTSET
| enums.LOG_LEVEL.WARNING;
// TODO[OASIS-6649]: Don't use object type
// eslint-disable-next-line @typescript-eslint/ban-types
jsonSchemaValidator?: object;
userProfileService?: UserProfileService | null;
eventBatchSize?: number;
Expand Down Expand Up @@ -115,6 +119,8 @@ declare module '@optimizely/optimizely-sdk' {
// HTTP method with which to send the event.
httpVerb: 'POST';
// Value to send in the request body, JSON-serialized.
// TODO[OASIS-6649]: Don't use any type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
params: any;
}

Expand Down Expand Up @@ -159,6 +165,8 @@ declare module '@optimizely/optimizely-sdk' {
}

export type UserAttributes = {
// TODO[OASIS-6649]: Don't use any type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[name: string]: any;
};

Expand All @@ -183,6 +191,8 @@ declare module '@optimizely/optimizely-sdk' {
endOfRange: number;
}>;
audienceIds: string[];
// TODO[OASIS-6649]: Don't use object type
// eslint-disable-next-line @typescript-eslint/ban-types
forcedVariations: object;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/optimizely-sdk/lib/optimizely/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import eventTagsValidator from '../utils/event_tags_validator';
import notificationCenter from '../core/notification_center';
import projectConfig from '../core/project_config';
import userProfileServiceValidator from '../utils/user_profile_service_validator';
import stringValidator from '../utils/string_value_validator';
import * as stringValidator from '../utils/string_value_validator';
import projectConfigManager from '../core/project_config/project_config_manager';

var ERROR_MESSAGES = enums.ERROR_MESSAGES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@

/**
* Validates provided value is a non-empty string
* @param {string} input
* @return {boolean} True for non-empty string, false otherwise
* @param {unknown} input
* @return {boolean} true for non-empty string, false otherwise
*/
export var validate = function(input) {
export function validate(input: unknown): boolean {
return typeof input === 'string' && input !== '';
};

export default {
validate: validate,
};
}
Loading