Skip to content

Commit

Permalink
Get a list of all non strict packages
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperpeulen committed Apr 20, 2023
1 parent a24334d commit 5303b75
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 1 deletion.
67 changes: 67 additions & 0 deletions Issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
*What:*
We want to step our TS game in the monorepo and enable strict typescript in all packages!

*Why:*
Having TS track for you if a variable might be null or not, enables us to code with much more confidence,
and also gives us quick in editor feedback, when you make assumptions that are not actually true!

*How:*
We would like to change as little as possible of the actual runtime behavior in this migration.
However, we also don't want to simply silence the compiler everywhere with `!`, `as` or `ts-ignore` to get this migration in.
As a rule of thumb, if the logic is easy enough, prefer improving the code (e.g. add a null check) over silencing the compiler.
If the change needed to do the right thing, is too risky, and not in your expertise, it is okay to silence the compiler.
It is not ideal, but we still gain the benefit that new code written will have extra typesafety.

Feel free to contribute too any of packages in the list below!

- [ ] @storybook/addon-backgrounds
- [ ] @storybook/addon-docs
- [ ] @storybook/addon-highlight
- [ ] @storybook/addon-interactions
- [ ] @storybook/addon-jest
- [ ] @storybook/addon-mdx-gfm
- [ ] @storybook/addon-measure
- [ ] @storybook/addon-outline
- [ ] @storybook/addon-storyshots
- [ ] @storybook/addon-storyshots-puppeteer
- [ ] @storybook/addon-storysource
- [ ] @storybook/addon-viewport
- [ ] @storybook/addons
- [ ] @storybook/angular
- [ ] @storybook/api
- [ ] @storybook/blocks
- [ ] @storybook/channel-postmessage
- [ ] @storybook/channel-websocket
- [ ] @storybook/channels
- [ ] @storybook/cli
- [ ] @storybook/client-api
- [ ] @storybook/codemod
- [ ] @storybook/components
- [ ] @storybook/core-client
- [ ] @storybook/core-events
- [ ] @storybook/core-server
- [ ] @storybook/csf-tools
- [ ] @storybook/docs-tools
- [ ] @storybook/external-docs
- [ ] @storybook/html-vite
- [ ] @storybook/instrumenter
- [ ] @storybook/manager
- [ ] @storybook/manager-api
- [ ] @storybook/postinstall
- [ ] @storybook/preact-vite
- [ ] @storybook/preset-create-react-app
- [ ] @storybook/preset-vue-webpack
- [ ] @storybook/preset-vue3-webpack
- [ ] @storybook/react-vite
- [ ] @storybook/router
- [ ] @storybook/scripts
- [ ] @storybook/server
- [ ] @storybook/source-loader
- [ ] @storybook/svelte-vite
- [ ] @storybook/sveltekit
- [ ] @storybook/theming
- [ ] @storybook/types
- [ ] @storybook/vue3-vite
- [ ] @storybook/vue3-webpack5
- [ ] @storybook/web-components
- [ ] @storybook/web-components-vite
3 changes: 2 additions & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"migrate-docs": "node --require esbuild-register ./ts-to-ts49.ts",
"task": "ts-node --swc ./task.ts",
"test": "jest --config ./jest.config.js",
"upgrade": "ts-node --swc ./task.ts"
"upgrade": "ts-node --swc ./task.ts",
"strict-ts": "node --require esbuild-register ./strict-ts.ts"
},
"husky": {
"hooks": {
Expand Down
41 changes: 41 additions & 0 deletions scripts/strict-ts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import glob from 'fast-glob';
import path from 'path';
import fsSync from 'node:fs';
import JSON5 from 'json5';

const files = glob.sync('**/*/tsconfig.json', {
absolute: true,
cwd: '..',
});

(async function main() {
const packages = files
.filter((file) => !file.includes('node_modules') && !file.includes('dist'))
.map((file) => {
const packageJson = path.join(path.dirname(file), 'package.json');
let packageName;
if (fsSync.existsSync(packageJson)) {
const json = fsSync.readFileSync(packageJson, { encoding: 'utf-8' });
packageName = JSON5.parse(json).name;
}

let strict;
if (fsSync.existsSync(file)) {
const tsconfig = fsSync.readFileSync(file, { encoding: 'utf-8' });
const tsconfigJson = JSON5.parse(tsconfig);
strict = tsconfigJson?.compilerOptions?.strict ?? false;
}

if (packageName && strict === false) {
return packageName;
}
return null;
})
.filter(Boolean)
.sort();

console.log(packages.join('\n'));
console.log(packages.length);

// console.log(files.filter((file) => !file.includes('node_modules') && !file.includes('dist')));
})();

0 comments on commit 5303b75

Please sign in to comment.