Where does tsc look to find the ts files for compilation?

Currently, I am delving into learning AngularJS v2 by thoroughly exploring the official documentation.

https://angular.io/docs/ts/latest/tutorial/toh-pt1.html

https://github.com/angular/quickstart

While experimenting with the tutorial mentioned in the links above, I was impressed to see that upon executing npm start, the application swiftly detected modifications in ts scripts and promptly compiled them into js. It's truly fascinating!

I'm now curious about the underlying code that enables this functionality.

Upon examining the package.json,

"scripts": {
    "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",

My assumption is that tsc handles the compilation aspect. What I find perplexing is how tsc identifies the location of ts files for compilation. Where can I access the settings for tsc? Are there options available to optimize the compilation process?

Answer №1

When the command tsc is called without any parameters, it automatically assumes that you want to compile all TypeScript files starting from your current directory downwards. It starts the search from the directory where the command was executed. (This behavior is not unique to tsc, as any executable can determine its execution location.) The command then recursively searches for any files with a .ts extension in itself and all subdirectories.

To customize compilation options, you can create a tsconfig.json file.

If you include a "files" array in the configuration, you can optimize the compilation process by narrowing down the search scope. However, the impact will be minimal unless you are dealing with a large directory structure.

Answer №2

In most cases, you'll come across a .babelrc file that is utilized by Babel.

This file contains all the necessary configurations for Babel to function properly:

{
  "presets": [
    ["@babel/preset-env", {
      "modules": "commonjs"
    }]
  ],
  "plugins": [
    "@babel/plugin-transform-runtime",
    "@babel/plugin-proposal-class-properties"
  ]
}

To specify the files that need to be transpiled, you can use the include option like so:

"include": [
    "src/**/*.js",
    "tests/**/*"
]

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Performing a synchronous request with AngularJS

How can I perform a synchronous server call in AngularJS? I want to achieve something like the jQuery code snippet below: var response = $.ajax( { type: "POST", url: "url", data: "data", async: false ...

What is the best way to access an external array using ng-repeat in AngularJS?

My dataset consists of 3 separate arrays. "areas": { "default": [ { "area": "Master Bedroom", "uuid": "986e3f42-1797-49ae-b060-181a33b9", "description": "", "new": [ { "value": "986e3f42-1797-49ae-b060-181a3 ...

What is the most effective way for server.js to send a request to a controller?

When I need to send data from a controller to my main server.js, I typically use the following method: $http.post('/auth/signup', user); This code is executed in the controller: app.post('/auth/signup', function(req, res, next) The ...

Angular variable named templateURL

I am relatively new to Angular as I have only been working with it for a couple of weeks. Currently, I am developing an app that displays data using charts and my goal is to allow the user to switch between different chart types by clicking a button. To a ...

Is there a way to export a specific portion of a destructuring assignment?

const { a, ...rest } = { a: 1, b: 2, c: 3 }; If I want to export only the rest object in TypeScript, how can I achieve that? ...

Error: Attempting to access the 'tokenType' property of an undefined object is not allowed

We encountered an error while attempting to embed a report using the Power BI Angular library. TypeError: Cannot read properties of undefined (reading 'tokenType') at isSaaSEmbedWithAADToken (reportEmbed?navContentPaneEnabled=false&uid=am ...

Refresh the cells in the UI ListView

Currently, I am working on implementing a long scrollable list of names for a PhoneGap (iOS) app using Onsen UI. To achieve this, I found a dynamic list view module that is compatible with this UI at the following link: Although I have managed to make it ...

The term 'shuterstock_init' is meant to be a type, however, it is mistakenly being treated as a value in this context

I am working on a service called class imageService, which mainly consists of key value pairs export type servicesName = "unsplash" | "pexels" | "pixabay" | 'shutterstock'; export type Service = { [key in services ...

Alert: an issue has been detected in the file located in the directory node_modules/pdfjs

My current project involves incorporating the use of ng2-pdf-viewer, as seen in the code snippet below: {PdfViewerModule} from 'ng2-pdf-viewer/ng2-pdf-viewer'; After upgrading to Angular 6, I have encountered a warning during ng build, even th ...

Changing the minimum value in an input type number with AngularJS

I am struggling to ensure that the minimum value for an input text box "number" is set to 1. I have a button that decrements it using AngularJS, but even with min="1" specified, the value goes below 1 when clicking the button. How can I maintain the minimu ...

Working with Firebase and handling asynchronous data retrieval: Implement success and error callbacks with the

I'm currently working on an Angular application that includes the following function: $scope.retrieveProjectData = function() { $scope.projectNumberNoChange = false; // Only fetch data if the ProjectNumber has changed if (cur ...

Exploring TypeScript Decorators and the Intricacies of Circular Dependencies

Take a look at this code snippet that involves inter-dependent code using decorators. Let's walk through the workflow where the actual classes are passed for later use: The application imports and executes Parent.ts @Test(Child) triggers the import ...

The validation for Australian mobile numbers should include the option to have spaces between the digits

How can I validate a mobile number properly? The first text input should start with 04 It should have a total of 10 digits, including 04 (e.g. 0412345678) Below is my input field: <form name="uploadForm"> <input type="tel" name="MobileNumber" ...

What is the best way to add multiple elements to an array simultaneously?

I am facing an issue with my array arrayPath. I am pushing multiple values into it, but there are duplicates in the data. When the value of singleFile.originalFilename is a duplicate, I do not want to push that duplicate value into arrayPath. How can I ach ...

When you neglect to include 'window' in your Angular expressions, you may encounter the error message "Window referencing is prohibited!"

Switching from AngularJS v1.2.17 to v1.2.28 brought about a surprise - one of my pages started throwing JavaScript errors, specifically: Error: [$parse:isecwindow] Referencing the Window in Angular expressions is disallowed! Expression: model.skAccoun ...

What is the best way to include $rootScope in an AngularJS unit test?

Imagine a scenario where there is a service in my application that relies on a value stored in $rootScope. The example below shows a simple service that does this: angular.module('myServices', []) .factory('rootValGetterService', funct ...

Calculating the grand total of items in the shopping cart

Greetings! I am diving into learning the ins and outs of the Angular framework. I managed to create a basic shopping cart following a tutorial that allows users to add products to their basket. However, I'm facing an issue where the total price is no ...

Refreshing the private route redirects the user to the login page

Currently, I am working on setting up a private route within my React app. I have integrated Redux and Redux-Toolkit (RTK) Query for handling state management and data fetching. The issue I am facing is that whenever I reload the private page, it redirects ...

Looking to integrate a widget into the pages of an Ionic 3 app?

I need to incorporate an external widget into my Ionic application. It's functioning properly when I add the script to my index.html and use the widget HTML element on the initial loading page (e.g. Home.html), but it isn't working on other pages ...

Travis build encountering issues with "The SUID sandbox helper binary was detected, however..."

My Angular app's tests are successfully passing on my local environment, however they encounter failures when run on Travis due to the following error message: An issue with the SUID sandbox helper binary has been detected, indicating improper conf ...