4

I am learning angular2 with typescript.Its quite fascinating to work but I am facing trouble understanding the actual working of any application as the code we have written will be in typescript.but the code to be executed is always in ECMAScript.

I have heard about transpiler but couldnt understand more about it.

I was just wondering how this functionality has been achieved?

1 Answer 1

3

There are two ways to do that:

  • Transpiling on the fly (like how it's done in plunkr):

    <script>
      System.config({
        transpiler: 'typescript', 
        typescriptOptions: { emitDecoratorMetadata: true }, 
        packages: {
          'app': {
            defaultExtension: 'ts'
          }
        } 
      });
      (...)
    </script>
    

    Here is a sample: https://plnkr.co/edit/aG4TdHbAls3cu04AAt64

  • Preprocess TypeScript files using the typeScript compiler. Then you only rely on compiled JavaScript files. Such approach is described in the 5min quickstart on angular.io: https://angular.io/guide/quickstart.

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.