pr05 Typescript #2: automatically resolve imports of ts files & migrate instance of client/utils file#3540
Conversation
khanniie
left a comment
There was a problem hiding this comment.
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!
khanniie
left a comment
There was a problem hiding this comment.
thanks so much!!! looking great!
| "@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.
do we need this, if we're not using the types yet?
There was a problem hiding this comment.
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.
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@typespackage forfriendly-words -
If
friendly-wordshas a peer dependencyother-package-Athat got installed along with it, or if it usesother-package-Ainternally, we do not need to install@typesforother-package-Aif we have"skipLibCheck": truein 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)
raclim
left a comment
There was a problem hiding this comment.
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)developbranch.Fixes #123