2

I am working on pretty big existing web application with team. Time to time we experience common JavaScript coding nuances like case difference while function calling or missing operator etc.

I find TypeScript promising solution for such issues specially while working with team on different files/modules. It has many benefits like

  • Static code analysis
  • Better auto-completion
  • Code Minification
  • Dead Code Reduction
  • String Type Checking
  • Strict OOP

I know there are converters available which can convert JavaScript to typescript but I do not want to convert existing project files to TypeScript.

I was wondering if it is possible to keep existing code as is and develop new modules/files in TypeScript. May be we can migrate existing files in gradual manner.

Will they work well together? How to do it?

I have tried to read online but couldn't find much relevant information other than converting existing projects to TypeScript.

1
  • 1
    You have to compile TypeScript to JavaScript anyway, just include the transform stage in your build process? If you have a large existing codebase I would keep .ts code somewhat separate. Commented Oct 15, 2015 at 8:03

1 Answer 1

2

Yes. From the language spec :

TypeScript is a syntactic sugar for JavaScript. TypeScript syntax is a superset of ECMAScript 6 (ES6) syntax.

Every JavaScript program is also a TypeScript program. The TypeScript compiler performs only file-local transformations on TypeScript programs and does not re-order variables declared in TypeScript. This leads to JavaScript output that closely matches the TypeScript input. TypeScript does not transform variable names, making tractable the direct debugging of emitted JavaScript. TypeScript optionally provides source maps, enabling source-level debugging. TypeScript tools typically emit JavaScript upon file save, preserving the test, edit, refresh cycle commonly used in JavaScript development.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.