Having trouble understanding why the command
tsc *.ts
isn't functioning correctly. The error message TS6053: File '*.ts' not found keeps appearing. Any suggestions on how to compile all the .ts files within a directory? Thank you!
Having trouble understanding why the command
tsc *.ts
isn't functioning correctly. The error message TS6053: File '*.ts' not found keeps appearing. Any suggestions on how to compile all the .ts files within a directory? Thank you!
When executing the tsc
command in the terminal without having a tsconfig file available, remember to provide it with a specific file name, such as app.ts
- the command will handle the dependencies for you, eliminating the need for wildcards.
However, if you do have a tsconfig.json file, simply run the tsc
command without specifying a file name argument and it will utilize the configuration settings, which may include the use of wildcards.
If you simply enter "tsc" in the terminal, it will automatically compile all of your TypeScript (.ts) files into JavaScript (.js) files. To bundle them together, you can use the command "tsc --outFile mybundle.js".
It's important to clarify that by bundling, it means consolidating all your JavaScript code into a single file. For more advanced configurations, consider setting up a tsconfig.json file as suggested by others.
Today, I ran into an issue while trying to execute 2 files in a folder that I created a few months ago when I first started learning Angular. Interestingly, I did not encounter this problem back then.
Important to note: The file had remained untouched since the initial modification and executed successfully at that time.
Although not the most ideal solution, the following workaround worked for me today.
Situation: In a folder containing "LikesComponent.ts" and "main.ts" files, I needed to execute both TS files to obtain the output. So I ran
tsc *.ts && node main.js
An error popped up:
error TS6053: File '*.ts' not found.
Found 1 error.
However, running the command below resolved the issue:
tsc LikesComponent.ts main.ts && node main.js
Dealing with a similar issue myself, you might want to give this command a shot: tsc --outFile file.js file.ts
It appears that the solution marked as correct may not be the best approach, especially if you are new to Angular and following tutorials by Mosh.
The alternative solution would be to simply execute the root file where all other modules are imported. In my case, this file is main.ts, and below is the command I used to run it:
$tsc main.ts && node main.js
If you're operating on a linux system, try this out:
find . -name "*.ts" | xargs tsc
The xargs utility will transform the results of the find command into arguments for the tsc compiler.
Keep in mind that this approach also covers subdirectories:
find src/ -name "*.ts" | xargs tsc
My typescript dictionary is filled with code. var dictionaryOfScores: {[id: string]: number } = {}; Now that it's populated, I want to sort it based on the value (number). Since the dictionary could be quite large, I'm looking for an in-place ...
Recently, I started working with Typescript and Aurelia framework. Currently, I am facing an issue while trying to implement the @autoinject decorator in a VS2015 ASP.NET MVC 6 project. Below is the code snippet I am using: import {autoinject} from "aure ...
Celebrating a Decade of TypeScript remarked that "It’s quite remarkable how the design goals set for TypeScript have stood the test of time." I am particularly intrigued by the goal of "Avoid adding expression-level syntax." One user even brought up thi ...
My challenge is dealing with an array of Google Map Embed API URLs. As I iterate over each item, I need to bind them to the source of an iFrame. I have a solution in mind: constructor(private sanitizer: DomSanitizationService) { this.url = sanitizer. ...
I am trying to extract values from JSON without the parent keys. Here is the JSON structure I have: [ { "companies": [{ "id": 1, "name": "Prueba", "company_number": "23423423A", "latitude": 241241.12, "lo ...
My Typescript app is built on AngularJS 2 with ASP.NET Core, and currently I store my TS files in the wwwroot directory. While this setup works well during development, I am concerned about how it will function in production. I aim to deploy only minified ...
Currently, I have my own internal function defined in the greatRoute.ts file: //in greatRoute.ts async function _secretString(param: string): Promise<string> { ... } router .route('/foo/bar/:secret') .get( async (...) => { ...
After setting up my tsconfig file to build a frontend typescript application with a single output structure, I encountered an unexpected issue: { "compilerOptions": { "target": "es5", "module": "system", "lib": [ "e ...
Presenting a custom button with the following code snippet: export default function CustomButton(isValid: any, email: any) { return ( <Button type="submit" disabled={!isValid || !email} style={{ ...
My question relates to a piece of TypeScript code Here is the code snippet: export function load_form_actions() { $('#step_2_form').on('ajax:before', function(data) { $('#step_2_submit_btn').hide(); $(&ap ...
I am encountering an issue while trying to add an authHeader to the "Service". The error message displayed is: Type '{ 'x-access-token': any; } | { 'x-access-token'?: undefined; }' is not assignable to type 'AxiosRequest ...
Looking to convert plain AngularJS code to Typescript? Take a look at this example: app.someController = function ($scope) { // var $scope.Data = null; var $scope.Data: SomeCollection = null; I need to associate Data with scope and specify it as type ...
Issue with Route Guard in Angular Application: I encountered an issue with my route guard in my Angular application. The problem arises when the guard is active and runs a check by calling a service to retrieve a value. This value is then mapped to true or ...
I have captured screenshots of the application: https://ibb.co/NmnSPNr and https://ibb.co/C0nwG4D info.component.ts / The Info component is a child component of the Item component, displayed when a specific link is routed to. export class InfoComponent imp ...
When calling a function, I have been passing "undefined" multiple times as a parameter. However, the SonarQube report is flagging an error stating "Remove this redundant undefined". https://i.stack.imgur.com/YhOZW.png It should be noted that the function ...
I am trying to configure a basic test runner using Karma in order to test a TypeScript class. However, when I attempt to run the tests with karma start, I encounter an error stating that ReferenceError: Calculator is not defined. It seems like either the ...
I'm interested in automating the process of utilizing an object's toString() method when it is implicitly converted to a string. Let's consider this example class: class Dog { name: string; constructor(name: string) { this.name = na ...
Currently, I am working with an API controller that requires a body parameter as shown below: insertUser(@Body() user: IUser) {} The problem I'm facing is that I can submit an object that includes additional properties not specified in the IUser int ...
Take this scenario for instance async function a() { await null; } In VS Code, there is a minor warning about using await: 'await' has no effect on the type of this expression. ts(80007) Is there a way to elevate that warning to an error in b ...
I recently developed a custom QR code reader feature as a button within the Formik component customTextInput.tsx, but I encountered an issue where clicking on the button would trigger a submission without any value present. The following code snippet show ...