From 44e2783b6a87bca49fb1d5bcffa45b22adc77bbc Mon Sep 17 00:00:00 2001 From: Kevin Ghadyani <97464104+KevinGhadyani-Okta@users.noreply.github.com> Date: Mon, 13 Mar 2023 11:32:01 -0500 Subject: [PATCH] fix: added TypeScript project references for VSCode (#1708) --- package.json | 19 ++++++++++--------- packages/odyssey-react-labs/package.json | 4 ++-- .../tsconfig.production.json | 12 +++++++++--- packages/odyssey-react-mui/package.json | 4 ++-- .../tsconfig.production.json | 5 +++-- packages/odyssey-storybook/package.json | 9 ++++++--- packages/odyssey-storybook/tsconfig.json | 10 +++++++++- packages/odyssey-storybook/types.d.ts | 13 ------------- .../odyssey-typescript/tsconfig.react.json | 8 ++++---- yarn.lock | 1 + 10 files changed, 46 insertions(+), 39 deletions(-) delete mode 100644 packages/odyssey-storybook/types.d.ts diff --git a/package.json b/package.json index 396162673f..ef57925c16 100644 --- a/package.json +++ b/package.json @@ -11,21 +11,22 @@ "node": ">=16 <17" }, "scripts": { - "start": "yarn build && npm-run-all --parallel start:mui start:labs start:storybook", - "start:labs": "yarn workspace @okta/odyssey-react-labs dev", - "start:mui": "yarn workspace @okta/odyssey-react-mui dev", - "start:storybook": "yarn workspace @okta/odyssey-storybook start", - "lerna-version": "lerna version --no-git-tag-version --include-merged-tags --conventional-commits --no-push --force-publish", + "build": "lerna run build --ignore @okta/odyssey-storybook", + "dev:source": "lerna run dev:source", + "eslint": "eslint . --ext .js,.jsx,.ts,.tsx", "lerna-publish": "lerna publish from-package --no-push --force-publish --no-verify-registry", + "lerna-version": "lerna version --no-git-tag-version --include-merged-tags --conventional-commits --no-push --force-publish", "lint": "yarn eslint && yarn stylelint && yarn prettier-check", + "postinstall": "yarn build && [ -z ${CI:-} ] && husky install || exit 0", "prettier-check": "prettier --ignore-unknown --loglevel warn --check .", "prettier-write": "prettier --ignore-unknown --loglevel warn --write .", - "eslint": "eslint . --ext .js,.jsx,.ts,.tsx", + "start:labs": "yarn workspace @okta/odyssey-react-labs dev", + "start:mui": "yarn workspace @okta/odyssey-react-mui dev", + "start:storybook": "yarn workspace @okta/odyssey-storybook start", + "start": "npm-run-all --sequential build --parallel dev:source start:storybook", "stylelint": "stylelint **/*.scss", "test": "lerna run test", - "typecheck": "lerna run typecheck", - "build": "lerna run build --ignore @okta/odyssey-storybook", - "postinstall": "yarn build && [ -z ${CI:-} ] && husky install || exit 0" + "typecheck": "lerna run typecheck" }, "devDependencies": { "@commitlint/cli": "^14.0.0", diff --git a/packages/odyssey-react-labs/package.json b/packages/odyssey-react-labs/package.json index 515fe31c59..435c17d1d7 100644 --- a/packages/odyssey-react-labs/package.json +++ b/packages/odyssey-react-labs/package.json @@ -7,11 +7,11 @@ "sideEffects": false, "main": "dist/index.js", "module": "dist/index.js", - "types": "dist/index.d.ts", + "types": "dist/src/index.d.ts", "exports": { ".": { "default": "./dist/index.js", - "types": "./dist/index.d.ts" + "types": "./dist/src/index.d.ts" } }, "repository": { diff --git a/packages/odyssey-react-labs/tsconfig.production.json b/packages/odyssey-react-labs/tsconfig.production.json index c04175b842..aa8523bc57 100644 --- a/packages/odyssey-react-labs/tsconfig.production.json +++ b/packages/odyssey-react-labs/tsconfig.production.json @@ -1,8 +1,14 @@ { "extends": "@okta/odyssey-typescript/tsconfig.react.types.json", "compilerOptions": { - "outDir": "dist", - "jsx": "react-jsx" + "composite": true, + "jsx": "react-jsx", + "outDir": "dist" }, - "exclude": ["./test", "**/*.test.**", "**/dist/**/*"] + "exclude": ["./test", "**/*.test.**", "**/dist/**/*"], + "references": [ + { + "path": "../odyssey-react-mui/tsconfig.production.json" + } + ] } diff --git a/packages/odyssey-react-mui/package.json b/packages/odyssey-react-mui/package.json index c70de8633d..bd270f5332 100644 --- a/packages/odyssey-react-mui/package.json +++ b/packages/odyssey-react-mui/package.json @@ -7,11 +7,11 @@ "sideEffects": false, "main": "dist/index.js", "module": "dist/index.js", - "types": "dist/index.d.ts", + "types": "dist/src/index.d.ts", "exports": { ".": { "default": "./dist/index.js", - "types": "./dist/index.d.ts" + "types": "./dist/src/index.d.ts" } }, "repository": { diff --git a/packages/odyssey-react-mui/tsconfig.production.json b/packages/odyssey-react-mui/tsconfig.production.json index c04175b842..d6af3f1166 100644 --- a/packages/odyssey-react-mui/tsconfig.production.json +++ b/packages/odyssey-react-mui/tsconfig.production.json @@ -1,8 +1,9 @@ { "extends": "@okta/odyssey-typescript/tsconfig.react.types.json", "compilerOptions": { - "outDir": "dist", - "jsx": "react-jsx" + "composite": true, + "jsx": "react-jsx", + "outDir": "dist" }, "exclude": ["./test", "**/*.test.**", "**/dist/**/*"] } diff --git a/packages/odyssey-storybook/package.json b/packages/odyssey-storybook/package.json index 37b22edb24..35e279278f 100644 --- a/packages/odyssey-storybook/package.json +++ b/packages/odyssey-storybook/package.json @@ -35,15 +35,18 @@ "@types/react": "^17.0.30", "babel-loader": "^8", "markdown-to-jsx": "^7.1.7", + "npm-run-all": "^4.1.5", "react": "^17.0.2", "react-dom": "^17.0.2", "typescript": "^4.9.4", "webpack": "4.46.0" }, "scripts": { - "start": "start-storybook --quiet --port 6006", "build": "build-storybook --quiet --output-dir dist", - "typecheck": "tsc", - "prepack": "yarn build && yarn exec prepack" + "prepack": "yarn build && yarn exec prepack", + "start:storybook": "start-storybook --quiet --port 6006", + "start:types": "tsc --build --watch", + "start": "npm-run-all --parallel start:types start:storybook", + "typecheck": "tsc" } } diff --git a/packages/odyssey-storybook/tsconfig.json b/packages/odyssey-storybook/tsconfig.json index 4b8b858e23..f2b4be8ad5 100644 --- a/packages/odyssey-storybook/tsconfig.json +++ b/packages/odyssey-storybook/tsconfig.json @@ -2,5 +2,13 @@ "extends": "@okta/odyssey-typescript/tsconfig.react.json", "compilerOptions": { "jsx": "react-jsx" - } + }, + "references": [ + { + "path": "../odyssey-react-mui/tsconfig.production.json" + }, + { + "path": "../odyssey-react-labs/tsconfig.production.json" + } + ] } diff --git a/packages/odyssey-storybook/types.d.ts b/packages/odyssey-storybook/types.d.ts deleted file mode 100644 index 2b856ecf4c..0000000000 --- a/packages/odyssey-storybook/types.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -/*! - * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved. - * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.") - * - * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * - * See the License for the specific language governing permissions and limitations under the License. - */ - -declare module "*.module.scss"; diff --git a/packages/odyssey-typescript/tsconfig.react.json b/packages/odyssey-typescript/tsconfig.react.json index 90dae61430..372e9010c5 100644 --- a/packages/odyssey-typescript/tsconfig.react.json +++ b/packages/odyssey-typescript/tsconfig.react.json @@ -2,11 +2,11 @@ "extends": "./tsconfig.strict.json", "compilerOptions": { + "isolatedModules": true, + "jsx": "react", "lib": ["dom", "es2020"], - "noEmit": true, "module": "es2020", - "target": "es2020", - "isolatedModules": true, - "jsx": "react" + "noEmit": true, + "target": "es2020" } } diff --git a/yarn.lock b/yarn.lock index 0937b6fe7d..01083e8a11 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6553,6 +6553,7 @@ __metadata: "@types/react": ^17.0.30 babel-loader: ^8 markdown-to-jsx: ^7.1.7 + npm-run-all: ^4.1.5 react: ^17.0.2 react-dom: ^17.0.2 typescript: ^4.9.4