|
|
|
|
|
by amoerie
2492 days ago
|
|
Generally, try the following steps: - turn off strict flags, turn them on again after everything compiles in non strict mode
- ensure you have the correct typings for the libraries you're using. Some libraries include them, others require a @typings/xyz dependency. (E.g. React and ReactDOM)
- try to hunt down the root errors. Much like C# or Java, one error can lead to hundreds of compilation errors down the line, but fixing the first root error can also make all of them go away in one fell swoop.
- try to keep things simple and non dynamic. Typescript is very flexible and powerful, but think twice before you use crazy constructs.
- enable emitOnError. It will allow you to test while you refactor, even though typescript complains.
- ask yourself: if it works and typescript does not compile, is it because typescript can't understand or is it because typescript is seeing possible issues you've not taken into account?
- don't think of typescript as something to get around of. Think of it as a helping hand that will guide you in your daily work and prevent a whole swath of runtime errors, but it needs to be fed with information about your data structures and libraries to work properly. |
|