-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
pr05 Typescript #2: automatically resolve imports of ts files & migrate instance of client/utils file #3540
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
pr05 Typescript #2: automatically resolve imports of ts files & migrate instance of client/utils file #3540
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM to me so far but would love to re-approve once the first PR is in just to see the diff without the forked changes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks so much!!! looking great!
@@ -114,6 +118,7 @@ | |||
"@svgr/webpack": "^6.2.1", | |||
"@testing-library/jest-dom": "^5.15.0", | |||
"@testing-library/react": "^12.1.2", | |||
"@types/friendly-words": "^1.2.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this, if we're not using the types yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this may be a misunderstanding but i thought we'd only need it if we did something like import {aType} from '@types/sdfdsf' to use aType later on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yess that's a good point!! I did some searching to double-check on this bc we also have "skipLibCheck": true
(https://github.com/processing/p5.js-web-editor/blob/develop/tsconfig.base.json#L7), which should allow us to not have to have declaration files within packages in node_modules, but I think it works the following way:
-
If a file is now in typescript and we import another package from node_modules explicitly (eg.
import friendlyWords from 'friendly-words'
https://github.com/processing/p5.js-web-editor/pull/3540/files#diff-f9bdb3c3bbc05033b909e04fcb4a39d7cb8b59f78ae786ab477b20a4a765ec53R1, then we need to install the@types
package forfriendly-words
-
If
friendly-words
has a peer dependencyother-package-A
that got installed along with it, or if it usesother-package-A
internally, we do not need to install@types
forother-package-A
if we have"skipLibCheck": true
in the TS config settings
So I think this is expected, and as we go we will likely have to continue installing @types
packages for any third-party packages we are using in a file that is being migrated (eg. react-router-dom
, jest-react
etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you claire!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me, thanks so much @clairep94 and @khanniie!
pr05 Typescript Migration: Auto-resolve import of ts files & migrate instance of client/utils file
IMPORTANT: Should be reviewed after #3533 for clarity
Context:
Changes:
client/utils/generateRandomName
& associated mockclient/utils/isSecurePage
-- checked and this utility function is unused in the projectNotes:
I have verified that this pull request:
npm run lint
)npm run test
)develop
branch.Fixes #123