4 ms·
> I figure there must be something wrong in my approach or in my ts config (no explicit any). This is a heretic/unpopular opinion, but I think especially for e
by kall 6y ago
> I figure there must be something wrong in my approach or in my ts config (no explicit any).
This is a heretic/unpopular opinion, but I think especially for existing JS/React projects, the laxest possible TS setting is the way to go.
You should be able to get to no type errors in your existing JS project with not too many changes. In these contexts (existing projects) I like to think of TS as more editor experience support than seperate language. Modern React is very friendly to TS automatic type inference, so IMHO you should be getting decent benefits from typescript without annotating anything at all. And instead of fixing complicated type errors for no real gain, just // @ts-ignore and move on.
I don't know what your specific issue is with styled-components. Should work pretty much out of the box? My suggestion would be to use CSS objects over string literals because that way you get typechecking for your CSS.
- rkwz 6y ago> This is a heretic/unpopular opinion, but I think especially for existing JS/React projects, the laxest possible TS setting is the way to go. Not sure why you think it's "heretic/unpopular", but I think it's the only reasonable way to incrementally migrate an existing codebase to TypeScript.
- kall 6y agoi‘ve read things to the effect of "if you don‘t use noImplicitAny and strictNullChecks you don‘t understand typescript" a bunch but I‘m glad to see the other approach is popular as well.
- bavell 6y agoIMO this is a very pragmatic approach to converting a large project from JS to TS. It's the approach I've been using to gradually convert large existing codebases over to TS without committing to a huge up-front refactor. Definitely agree with you about the IDE experience, just that alone is enough for me to justify the transition.
- outside1234 6y agoI used this approach in a project I migrated to TypeScript as well. My strategy was to start loose, fix those warnings, and then gently turn up the rigor when I had the energy to fix the resultant warnings.
- deckard1 6y ago.
- jfkebwjsbx 6y agoThat is a management problem, not a development one. The company must pay someone to do the cleanup. Otherwise, of course it won’t work.