Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added TypeScript project references for VSCode #1708

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/odyssey-react-labs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
12 changes: 9 additions & 3 deletions packages/odyssey-react-labs/tsconfig.production.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
4 changes: 2 additions & 2 deletions packages/odyssey-react-mui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src folder in dist? That is not common, right? Can we avoid that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Only the TS files because isolateModules: true.

Copy link
Contributor Author

@KevinGhadyani-Okta KevinGhadyani-Okta Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how it was the whole time. I don't think it's easy or necessary to fix.

Most libraries export a single index.d.ts, but if you saw ours, this makes more sense. In the timeframe, I wasn't able to get a single index.d.ts working with outFile.

"exports": {
".": {
"default": "./dist/index.js",
"types": "./dist/index.d.ts"
"types": "./dist/src/index.d.ts"
}
},
"repository": {
Expand Down
5 changes: 3 additions & 2 deletions packages/odyssey-react-mui/tsconfig.production.json
Original file line number Diff line number Diff line change
@@ -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/**/*"]
}
9 changes: 6 additions & 3 deletions packages/odyssey-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
10 changes: 9 additions & 1 deletion packages/odyssey-storybook/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
13 changes: 0 additions & 13 deletions packages/odyssey-storybook/types.d.ts

This file was deleted.

8 changes: 4 additions & 4 deletions packages/odyssey-typescript/tsconfig.react.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down