Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(init): TypeScript code is not being recompiled automatically (#11470
) The use of `npx ts-node` to run the app in the TypeScript init templates is intended to make sure the source code gets transpiled before every synth without the user needing to `npm run build` explicitly. I have had reports on the Hello World dev guide topic that an `npm run build` is still needed, even though it shouldn't be. I was able to reproduce this issue today (was not able to do so previously). The problem is that, by default, `ts-node` prefers resolving imports to JavaScript files. If a JavaScript file exists, as it would be after the first build, it is simply imported as-is. The corresponding TypeScript module is not transpiled. Therefore changes you make to the TS code are never picked up and stale JS code is used. The flag `--prefer-ts-exts` solves this issue. It causes module imports to prefer importing TypeScript files, which means that the modules will get recompiled if necessary. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information