Skip to content

Commit

Permalink
Merge pull request #4451 from mzedel/fix/master-is-no-release-branch
Browse files Browse the repository at this point in the history
Revert: "revert: Revert "chore: introduced typescript support""
  • Loading branch information
mzedel committed Jun 19, 2024
2 parents 84e2c66 + 73dc87c commit a124f77
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 21 deletions.
1 change: 1 addition & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"useBuiltIns": "usage"
}
],
"@babel/preset-typescript",
["@babel/preset-react", { "runtime": "automatic" }]
],
"plugins": ["@babel/plugin-syntax-dynamic-import", "@babel/plugin-transform-runtime"]
Expand Down
67 changes: 51 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
"@trivago/prettier-plugin-sort-imports": "4.3.0",
"@typescript-eslint/eslint-plugin": "7.11.0",
"@typescript-eslint/parser": "7.11.0",
"@babel/preset-typescript": "^7.21.4",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"assert": "2.1.0",
"autoprefixer": "10.4.19",
"babel-jest": "~29.7.0",
Expand Down Expand Up @@ -101,6 +106,7 @@
"process": "0.11.10",
"redux-mock-store": "1.5.4",
"stream-browserify": "3.0.0",
"typescript": "^5.2.2",
"undici": "^5.28.4",
"util": "0.12.5",
"webpack": "5.91.0",
Expand Down Expand Up @@ -180,13 +186,14 @@
]
},
"scripts": {
"build": "webpack --mode production --entry ./src/js/main.js",
"build": "webpack --mode production",
"disclaim": "yarn licenses generate-disclaimer > disclaimer.txt",
"lint": "eslint src && eslint tests",
"lint-fix": "eslint --fix src && eslint --fix tests",
"serve": "./entrypoint.sh && webpack serve --mode development --entry ./src/js/main.js",
"serve": "./entrypoint.sh && webpack serve --mode development",
"test": "node test.js",
"watch": "webpack --watch --mode development --entry ./src/js/main.js"
"test-types": "tsc --project ./tsconfig-test.json",
"watch": "webpack --watch --mode development"
},
"author": "Northern.tech AS",
"license": "Apache-2.0",
Expand Down
3 changes: 3 additions & 0 deletions scripts/typeGeneration/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ const generateTypeIndex = async () => {
if (line.startsWith('/* ')) {
accu.push(line);
} else if (line.includes(`from './models/`)) {
if (line.endsWith('/models/Settings";')) {
accu.push('// @ts-ignore');
}
accu.push(line.replace('/models', ''));
}
return accu;
Expand Down
6 changes: 6 additions & 0 deletions tests/licenses/directDependencies.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"@babel/plugin-transform-runtime","MIT","https://github.com/babel/babel"
"@babel/preset-env","MIT","https://github.com/babel/babel"
"@babel/preset-react","MIT","https://github.com/babel/babel"
"@babel/preset-typescript","MIT","https://github.com/babel/babel"
"@emotion/jest","MIT","https://github.com/emotion-js/emotion.git#main"
"@emotion/react","MIT","https://github.com/emotion-js/emotion.git#main"
"@emotion/styled","MIT","https://github.com/emotion-js/emotion.git#main"
Expand All @@ -22,6 +23,10 @@
"@testing-library/react","MIT","https://github.com/testing-library/react-testing-library"
"@testing-library/user-event","MIT","https://github.com/testing-library/user-event"
"@trivago/prettier-plugin-sort-imports","Apache-2.0","https://github.com/trivago/prettier-plugin-sort-imports"
"@types/jest","MIT","https://github.com/DefinitelyTyped/DefinitelyTyped"
"@types/node","MIT","https://github.com/DefinitelyTyped/DefinitelyTyped"
"@types/react-dom","MIT","https://github.com/DefinitelyTyped/DefinitelyTyped"
"@types/react","MIT","https://github.com/DefinitelyTyped/DefinitelyTyped"
"@typescript-eslint/eslint-plugin","MIT","https://github.com/typescript-eslint/typescript-eslint"
"@typescript-eslint/parser","BSD-2-Clause","https://github.com/typescript-eslint/typescript-eslint"
"@xterm/addon-fit","MIT","https://github.com/xtermjs/xterm.js.git#master"
Expand Down Expand Up @@ -91,6 +96,7 @@
"redux-thunk","MIT","https://github.com/reduxjs/redux-thunk"
"stream-browserify","MIT","https://github.com/browserify/stream-browserify"
"tss-react","MIT","https://github.com/garronej/tss-react"
"typescript","Apache-2.0","https://github.com/Microsoft/TypeScript"
"undici","MIT","https://github.com/nodejs/undici"
"universal-cookie","MIT","https://github.com/bendotcodes/cookies"
"util","MIT","https://github.com/browserify/node-util"
Expand Down
9 changes: 9 additions & 0 deletions tsconfig-test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"noEmit": true,
"skipLibCheck": true,
"noResolve": true
},
"extends": "./tsconfig.json",
"exclude": ["src/js/api/types/Settings.ts"]
}
23 changes: 23 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"checkJs": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "react-jsx",
"lib": ["dom", "dom.iterable", "esnext"],
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": false,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "esnext"
},
"include": ["./src/**/*.ts"]
}
6 changes: 4 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ export default (env, argv) => {
node: {
global: true
},
entry: './src/js/main.js',
module: {
rules: [
{
test: /\.m?[jt]s[x]?$/,
test: /\.m?[jt]sx?$/,
exclude: [/node_modules/, /\.test\./, /__snapshots__/],
resolve: { fullySpecified: false },
loader: 'esbuild-loader',
options: {
loader: 'jsx',
loader: 'tsx',
jsx: 'automatic'
}
},
Expand Down Expand Up @@ -118,6 +119,7 @@ export default (env, argv) => {
alias: {
'@babel/runtime/helpers/esm': path.resolve(__dirname, 'node_modules/@babel/runtime/helpers/esm')
},
extensions: ['.ts', '.tsx', '.js', '.jsx'],
fallback: {
assert: require.resolve('assert/'),
buffer: require.resolve('buffer/'),
Expand Down

0 comments on commit a124f77

Please sign in to comment.