Skip to content

Commit

Permalink
strictNullsCheck migration: core (stream-labs#2359)
Browse files Browse the repository at this point in the history
* convert core

* remove comments

* add files
  • Loading branch information
holiber authored and avacreeth committed Dec 21, 2019
1 parent fe2098b commit 12fd897
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/services/core/persistent-stateful-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export abstract class PersistentStatefulService<TState extends object> extends S
static defaultState = {};

static get initialState() {
const persisted = JSON.parse(localStorage.getItem(this.localStorageKey)) || {};
const persisted = JSON.parse(localStorage.getItem(this.localStorageKey) as string) || {};

return merge({}, this.defaultState, persisted);
}
Expand Down
2 changes: 1 addition & 1 deletion app/services/core/stateful-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function inheritMutations(target: any) {
registerMutation(
target.prototype,
methodName,
Object.getOwnPropertyDescriptor(target.prototype, methodName),
Object.getOwnPropertyDescriptor(target.prototype, methodName) as PropertyDescriptor,
baseClassProto.mutationOptions[methodName],
);
});
Expand Down
3 changes: 3 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
- script: 'yarn lint'
displayName: 'TSLint'

- script: 'yarn compile:strictnulls'
displayName: 'Check regressions in files with strictNullChecks'

- script: 'yarn compile:ci'
displayName: 'Compile Assets'

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"compile:ci": "yarn clear && yarn compile:updater && yarn webpack-cli --config dev.config.js",
"compile:production": "yarn clear && yarn compile:updater && yarn webpack-cli --progress --config prod.config.js",
"compile:updater": "rimraf updater/build && tsc -p updater",
"compile:strictnulls": "yarn clear && yarn compile:updater && yarn webpack-cli --progress --config strict-null-check.config.js",
"webpack-cli": "node --max-old-space-size=4096 node_modules/webpack-cli/bin/cli.js",
"watch": "yarn clear && yarn compile:updater && yarn webpack-cli --watch --progress --config dev.config.js",
"watch-app": "yarn clear && yarn webpack-cli --watch --progress --config dev-app.config.js",
Expand Down
8 changes: 8 additions & 0 deletions strict-null-check-files/core.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ts": [
"app/services/core/*.ts"
],
"tsx": [

]
}
67 changes: 67 additions & 0 deletions strict-null-check.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const merge = require('webpack-merge');
const baseConfig = require('./base.config.js');
const path = require('path');
const fs = require('fs');

// read all files eligible for the strictNulls checking
const filesPath = 'strict-null-check-files';
const files = fs.readdirSync(filesPath);
const tsFiles = [];
const tsxFiles = [];
files.forEach(file => {
const json = JSON.parse(fs.readFileSync(`${filesPath}/${file}`));
if (json.ts) tsFiles.push(...json.ts);
if (json.tsx) tsxFiles.push(...json.tsx);
});


module.exports = merge.smart(baseConfig, {
entry: {
renderer: './app/app.ts',
updater: './updater/ui.js',
'guest-api': './guest-api'
},

mode: 'development',
watchOptions: { ignored: /node_modules/ },

optimization: {
usedExports: true,
},

module: {
rules: [
{
test: /\.ts$/,
loader: 'awesome-typescript-loader',
options: {
useCache: true,
reportFiles: [
...tsFiles
],
strictNullChecks: true
},
exclude: /node_modules|vue\/src/
},
{
test: /\.tsx$/,
include: path.resolve(__dirname, 'app/components'),
loader: [
'babel-loader',
{
loader: 'awesome-typescript-loader',
options: {
forceIsolatedModules: true,
reportFiles: [
...tsxFiles
],
configFileName: 'tsxconfig.json',
instance: 'tsx-loader'
}
}
],
exclude: /node_modules/,
},
],
}
});

0 comments on commit 12fd897

Please sign in to comment.