This repository has been archived by the owner on Aug 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dhoko
reviewed
Sep 23, 2019
vincaslt
commented
Sep 23, 2019
vincaslt
commented
Sep 23, 2019
dhoko
reviewed
Sep 23, 2019
vincaslt
force-pushed
the
feat/typescript
branch
from
September 23, 2019 10:18
8cb67f0
to
94bbc3f
Compare
We have lint-staged for this task, you can edit the config here https://github.com/ProtonMail/react-components/blob/master/package.json#L25 |
vincaslt
commented
Sep 23, 2019
vincaslt
force-pushed
the
feat/typescript
branch
2 times, most recently
from
October 1, 2019 07:33
746e13b
to
46188b3
Compare
vincaslt
force-pushed
the
feat/typescript
branch
from
October 2, 2019 10:24
0f61d2b
to
752968d
Compare
vincaslt
force-pushed
the
feat/typescript
branch
from
October 3, 2019 08:26
b484760
to
cdc32e9
Compare
EpokK
approved these changes
Oct 3, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Opened this PR to collect feedback and keep track of cleanup stuff.
Related PRs:
react-components
(this): #298 4️⃣proton-pack
: https://github.com/ProtonMail/proton-pack/pull/26/files 1️⃣proton-i18n
: ProtonMail/proton-i18n#9 2️⃣proton-shared
: https://github.com/ProtonMail/proton-shared/pull/53/files 3️⃣protonmail-settings
: ProtonMail/proton-mail-settings#131 5️⃣Implementing typescript support through babel loaders as opposed to webpack loaders. This will use
'@babel/preset-typescript'
to compile js and ts files.Caveats:
tsc
command on commit, which will do the type checking as part of compilation process.More info: https://iamturns.com/typescript-babel/
React typescript files should have
*.tsx
file extension, as it's the standard.Local JS files are recognized and type checked, so when
.js
functions/components are imported in.ts
files they will throw errors most of the time. The best solution is to rewrite the javascript file to typescript, but sometimes we might not have the time to do that. Typescript can understand types in js files from type comments, so we can provide types or disable checking for those functions, mostly happens with components that have optional props e.g.:IAmJavascriptCmp
will be marked with an error, asoptionalProp
is assumed to be missing.@type
override can prevent the errors (but should eventually be removed when files are rewritten in typescript)npm install --save -D @types/module-name
. Our projects are setup to recognize typescript files, and do not require declarations for them. However, javascript files are not recognized, so they need declarations. For example, if we haveproton-shared/lib/constants.js
file and import it from.ts
file:import { PERMISSIONS } from 'proton-shared/lib/constants';
it will say:Could not find a declaration file for module 'proton-shared/lib/constants'
.Best solution is to just rewrite the file to ts quickly, if the file is too large we can use
any
type for more complex declarations and just come back and fix those parts later. If that's not possible for some reason, we can declare a module inindex.d.ts
file:But that should be the last resort.