Skip to content

Commit

Permalink
chore(scripts): enable type-checks on ci and fix all ts-errors (#24264)
Browse files Browse the repository at this point in the history
* chore(scripts): enable type-checks on ci and fix all ts-errors

* chore(pr-deploy-site): fix ts-config
  • Loading branch information
Hotell authored Aug 11, 2022
1 parent 84e2b1a commit 512bac0
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"name": "Build @fluentui/react",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/scripts/just-scripts.js",
"program": "${workspaceRoot}/node-modules/just-scripts/bin/just-scripts.js",
"cwd": "${workspaceRoot}/packages/react",
"stopOnEntry": false,
"args": ["ts"],
Expand Down
3 changes: 2 additions & 1 deletion apps/pr-deploy-site/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../../scripts/tsconfig.json",
"compilerOptions": {
"noEmit": true,
"allowJs": true
"allowJs": true,
"lib": ["ES2020", "DOM"]
},
"include": ["pr-deploy-site.js", "just.config.ts"]
}
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"buildto": "lage build --verbose --to",
"buildto:lerna": "node ./scripts/monorepo/buildTo.js",
"bundle": "lage bundle --verbose",
"bundlesize": "cd scripts && yarn bundlesize",
"bundlesizecollect": "node ./scripts/bundle-size-collect",
"change": "beachball change --no-commit",
"check:change": "beachball check",
Expand Down Expand Up @@ -55,9 +54,7 @@
"runto:lerna": "node ./scripts/monorepo/runTo.js",
"scrub": "node ./scripts/scrub.js",
"start": "node scripts/start.js",
"start:legacy": "yarn workspace @fluentui/public-docsite-resources start",
"start:northstar": "yarn workspace @fluentui/docs start",
"start-exp": "yarn workspace @fluentui/react-experiments start",
"stats:build": "gulp stats",
"stats:save": "gulp stats:save",
"test": "lage test --verbose",
Expand Down Expand Up @@ -119,6 +116,7 @@
"@testing-library/react": "12.1.2",
"@testing-library/react-hooks": "7.0.2",
"@testing-library/user-event": "13.5.0",
"@tsconfig/node14": "1.0.3",
"@types/babel__helper-plugin-utils": "7.10.0",
"@types/copy-webpack-plugin": "6.4.0",
"@types/dedent": "0.7.0",
Expand Down Expand Up @@ -161,7 +159,7 @@
"beachball": "2.18.0",
"chalk": "4.1.0",
"ci-info": "3.2.0",
"clean-webpack-plugin": "3.0.0",
"clean-webpack-plugin": "4.0.0",
"cli-table3": "0.6.1",
"copy-webpack-plugin": "8.1.0",
"cross-env": "^5.1.4",
Expand Down
14 changes: 12 additions & 2 deletions packages/fluentui/perf-test-northstar/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
{
"extends": "@fluentui/scripts/typescript/tsconfig.common",
"compilerOptions": {
"moduleResolution": "node",
"module": "esnext",
"target": "es5",
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"skipLibCheck": true,
"lib": ["es2015", "dom"],
"strict": true,
"jsx": "react",
"rootDir": "src",
"outDir": "lib",
"types": ["node", "jest", "expect-puppeteer", "jest-environment-puppeteer", "webpack-env"]
"sourceMap": true,
"types": ["node", "jest", "expect-puppeteer", "jest-environment-puppeteer", "webpack-env"],
"noUnusedLocals": true
},
"include": ["src"],
"references": []
Expand Down
2 changes: 0 additions & 2 deletions scripts/beachball/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/// <reference types="jest" />

import { config as sharedConfig } from './shared.config';
import v8Config from './release-v8.config';
import vNextConfig from './release-vNext.config';
Expand Down
4 changes: 3 additions & 1 deletion scripts/beachball/release-v8.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @ts-check

require('../ts-node-register');
if (process.env.NODE_ENV !== 'test') {
require('../ts-node-register');
}

const { getConfig } = require('./utils');
const { config: sharedConfig } = require('./shared.config');
Expand Down
4 changes: 3 additions & 1 deletion scripts/beachball/release-vNext.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @ts-check

require('../ts-node-register');
if (process.env.NODE_ENV !== 'test') {
require('../ts-node-register');
}

const { getConfig } = require('./utils');
const { config: sharedConfig } = require('./shared.config');
Expand Down
1 change: 1 addition & 0 deletions scripts/gulp/plugins/util/parseTypeAnnotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const parseTypeAnnotation = (propName: string, propType: string, tsType: t.TSTyp
}

if (t.isTSLiteralType(tsType)) {
// @ts-expect-error - FIXME - `value` doesn't exist on literal
return [{ name: 'literal', value: tsType.literal.value.toString() }];
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/gulp/tasks/browserAdapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function checkDevtoolsAvailability(host, port, timeout): Promise<boolean>

socket.connect(port, host, () => {
socket.end();
resolve();
resolve(undefined);
});
});

Expand Down
2 changes: 0 additions & 2 deletions scripts/just-scripts.js

This file was deleted.

20 changes: 4 additions & 16 deletions scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@
"name": "@fluentui/scripts",
"version": "1.0.0",
"private": true,
"main": "./index.js",
"bin": {
"just-scripts": "./just-scripts.js"
},
"scripts": {
"build": "echo no-op",
"bundlesize": "bundlesize --debug",
"clean": "",
"code-style": "node ./just-scripts.js code-style",
"test": "jest"
"code-style": "just-scripts code-style",
"test": "jest",
"type-check": "tsc -p . --noEmit"
},
"devDependencies": {
"@fluentui/eslint-plugin": "*"
Expand Down Expand Up @@ -72,11 +66,5 @@
"resolve": "^1.7.1",
"riceburn": "^1.3.1",
"through2": "^2.0.3"
},
"bundlesize": [
{
"path": "../apps/test-bundles/dist/fluentui-react-Button.min.js",
"maxSize": "50.1 kB"
}
]
}
}
23 changes: 0 additions & 23 deletions scripts/publish-beta.js

This file was deleted.

2 changes: 0 additions & 2 deletions scripts/tasks/argv.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/// <reference types="jest" />

import { argv } from 'just-scripts';
import { Arguments } from 'yargs';

Expand Down
14 changes: 7 additions & 7 deletions scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"extends": "./typescript/tsconfig.common.json",
// This config is used for running build scripts through ts-node
"extends": "@tsconfig/node14/tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"target": "ES2018", // Node 10 per https://kangax.github.io/compat-table/es2016plus/#node10_9
"lib": ["ES2018", "DOM"], // Node 10, occasional test-related stuff that uses DOM
"esModuleInterop": true,
"noEmit": true,
"allowJs": true,
"noImplicitAny": false,
"strictNullChecks": false,
"outDir": "../../dist",
"sourceMap": true,
"typeRoots": ["../typings", "../node_modules/@types"],
"types": ["node", "webpack-env"]
"types": ["node", "jest"],
"noUnusedLocals": true
},
"include": ["."],
"exclude": ["./create-package/plop-templates*", "cypress.config.ts"]
"exclude": ["./cypress/**", "./cypress.js", "./cypress.config.ts"]
}
4 changes: 1 addition & 3 deletions scripts/typescript/normalize-import.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// @ts-check

/// <reference lib="es2019.array" />

const fs = require('fs');
const path = require('path');
const chalk = require('chalk');
Expand Down Expand Up @@ -84,7 +82,7 @@ function getAllFiles(dirPath, arrayOfFiles = []) {
return filePath;
});

return allFiles.flat(Infinity);
return /** @type {string[]} */ (allFiles.flat(Infinity));
}

/**
Expand Down
2 changes: 0 additions & 2 deletions scripts/typescript/normalize-import.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// @ts-check

/// <reference types="jest" />

const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
Expand Down
22 changes: 0 additions & 22 deletions scripts/typescript/tsconfig.common.json

This file was deleted.

10 changes: 2 additions & 8 deletions scripts/webpack/webpack.config.stats.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CleanWebpackPlugin from 'clean-webpack-plugin';
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
import fs from 'fs';
import path from 'path';
import webpack from 'webpack';
Expand Down Expand Up @@ -64,10 +64,7 @@ const makeConfig = (srcPath: string, name: string): webpack.Configuration => ({
optimization: {
minimizer: [
new TerserWebpackPlugin({
cache: true,
parallel: true,
sourceMap: false,

terserOptions: {
mangle: false,
output: {
Expand All @@ -81,10 +78,7 @@ const makeConfig = (srcPath: string, name: string): webpack.Configuration => ({
},
}),
plugins: [
new CleanWebpackPlugin([paths.base('stats')], {
root: paths.base(),
verbose: false, // do not log
}),
new CleanWebpackPlugin(),
new IgnoreNotFoundExportPlugin(),
// new BundleAnalyzerPlugin({
// reportFilename: `${name}.html`,
Expand Down
13 changes: 6 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4897,7 +4897,7 @@
resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d"
integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==

"@tsconfig/node14@^1.0.0":
"@tsconfig/node14@1.0.3", "@tsconfig/node14@^1.0.0":
version "1.0.3"
resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1"
integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==
Expand Down Expand Up @@ -5972,7 +5972,7 @@
"@types/source-list-map" "*"
source-map "^0.6.1"

"@types/webpack@*", "@types/webpack@^4", "@types/webpack@^4.4.31", "@types/webpack@^4.41.26", "@types/webpack@^4.41.8":
"@types/webpack@*", "@types/webpack@^4", "@types/webpack@^4.41.26", "@types/webpack@^4.41.8":
version "4.41.30"
resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.41.30.tgz#fd3db6d0d41e145a8eeeafcd3c4a7ccde9068ddc"
integrity sha512-GUHyY+pfuQ6haAfzu4S14F+R5iGRwN6b2FRNJY7U0NilmFAqbsOfK6j1HwuLBAqwRIT+pVdNDJGJ6e8rpp0KHA==
Expand Down Expand Up @@ -9054,12 +9054,11 @@ clean-stack@^2.0.0:
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b"
integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==

clean-webpack-plugin@3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/clean-webpack-plugin/-/clean-webpack-plugin-3.0.0.tgz#a99d8ec34c1c628a4541567aa7b457446460c62b"
integrity sha512-MciirUH5r+cYLGCOL5JX/ZLzOZbVr1ot3Fw+KcvbhUb6PM+yycqd9ZhIlcigQ5gl+XhppNmw3bEFuaaMNyLj3A==
clean-webpack-plugin@4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/clean-webpack-plugin/-/clean-webpack-plugin-4.0.0.tgz#72947d4403d452f38ed61a9ff0ada8122aacd729"
integrity sha512-WuWE1nyTNAyW5T7oNyys2EN0cfP2fdRxhxnIQWiAp0bMabPdHhoGxM8A6YL2GhqwgrPnnaemVE7nv5XJ2Fhh2w==
dependencies:
"@types/webpack" "^4.4.31"
del "^4.1.1"

cli-boxes@^1.0.0:
Expand Down

0 comments on commit 512bac0

Please sign in to comment.