Getting started with TypeScript and Azure CLI's 'az acr' command

Currently, I am in the process of developing a custom task for Azure DevOps Server 2019. While I have successfully created a .ps1 script for Windows, I am facing challenges with Linux. To tackle this, I have opted to write the script in TypeScript as I find it more preferable over writing in js. The script itself is quite straightforward.

let registry = "Registry3";//argv[1]
let timestamp = "2020-01-01";//argv[2]
let repository = "hello-world";//to be looped

az acr repository show-manifests --name registry --repository repository --orderby time_asc -o tsv;

Upon attempting to compile the script using tsc file.ts, an error arises:

Clean-ACR.ts:54:6 - error TS1005: ';' expected.

54   az acr repository show-manifests --name registry --repository repository --orderby time_asc -o tsv;
        ~~~

This error persists for each word from "acr" onwards until the end of the line. Clearly, TypeScript is struggling to interpret this particular line due to incorrect syntax. However, I am still uncertain about the correct way to execute this command. As a newcomer to TypeScript, I seek your understanding and pardon my lack of expertise.

Answer №1

To implement template strings, consider the following syntax:

`az acr ${repository} show-manifests --name ${registry} --repository ${repository} --orderby time_asc -o tsv`

Answer №2

If you're venturing into the realm of executing shell commands, consider delving into the world of bash scripts for a more efficient approach.

When it comes to incorporating TypeScript with node.js, make sure to utilize ts-node along with the child_process APIs provided by node.js.

For a demonstration that involves JavaScript (without requiring ts-node) yet still benefits from TypeScript type checking, check out this example: orta/make-monaco-builds/publish-monaco-ts.js

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

Unable to call a function on a type that does not have a callable signature

When working with TypeScript and using the react/lib/update method, I encountered an issue. I created a definition file for it like this: declare module 'react/lib/update' { export default function update<S>(value: S, spec: any): S; } ...

Angular 6 issue: Data not found in MatTableDataSource

Working on implementing the MatTableDataSource to utilize the full functionality of the Material Data-Table, but encountering issues. Data is fetched from an API, stored in an object, and then used to create a new MatTableDataSource. However, no data is b ...

Make sure to call the loader function in React Router only when there are path params present

I'm currently implementing the new React Router, utilizing loader functions to fetch data based on the loaded element. My goal is to have certain APIs called regardless of the route, with additional APIs triggered for specific routes. However, I&apos ...

Bringing @angular/code into a directory that is not within an Angular project

Currently, I have an Angular 2 project folder with a separate service folder named "auth.service.ts" located outside of it. Within this service file, I am importing `Injectable` from `@angular/core`. However, due to the service being located outside of t ...

Innovative approaches to enhancing Feathers services through the use of relational data in design patterns

I'm in the process of developing a straightforward application that involves a one-to-many relationship between data entities. Specifically, I am working with feathers js and sequelize (utilizing sqlite) to create a system where each site can have mul ...

"Exploring the depths of Webpack's module

This is my first venture into creating an Angular 2 application within MVC Core, utilizing TypeScript 2.2, Angular2, and Webpack. I have been closely following the Angular Documentation, but despite referencing the latest NPM Modules, I encounter errors w ...

Is there a ReactNode but with greater specificity?

In setting up the properties for a component, I have defined them as follows: interface HeaderProps{ title: string; image: string; link: ReactNode; } The 'link' property is meant to refer to another component, specifically <Link /> ...

Having trouble retrieving the Ionic 2 slides instance - getting a result of undefined

As I attempt to utilize the slides and access the instance in order to use the slideto functionality programmatically, I find myself encountering the issue of receiving 'undefined' back despite following the documentation. Here is my TypeScript ...

How to Validate Comma-Separated Email IDs Using Regex in Angular 5 Template?

I am currently working on a project utilizing Angular 5. Within this project, there is an input field designated for E-Mail IDs. The main goal I aimed to achieve was: To enable the user to input a maximum of 3 E-Mail IDs, with each E-Mail ID being subject ...

Struggling with getting autocomplete and auto import to work properly while working on an Angular project

After installing the latest version of VSCode on my Windows system, I proceeded to add language support for TypeScript and configure my editor settings by adjusting the font size, disabling the minimap, enabling autosave on focus change, and more. Addition ...

Encountering an ENOENT error in the CodeSandbox CI environment, whereas this issue does not arise in GitHub

I am currently in the process of creating a GitHub pull request for the react-querybuilder library. However, I am encountering an issue with my CodeSandbox CI job, which is failing and displaying the following error message: { [Error: ENOENT: no such file ...

How come Angular8's routerLinkActive is applying the active class to both the Home link and other links in the navigation bar simultaneously?

Currently, I am facing an issue with routing in my project where the home tab remains active even when I click on other tabs. I have tried adding routerLinkActiveOption as a solution, but it doesn't seem to be working for me. <ul class="nav nav-ta ...

Using TypeScript in Node.js to iterate through an asynchronous forEach loop

I attempted to integrate a database operation within an async forEach loop with the following code snippet: let successCounter = 0; let failureCounter = 0; let myData = [101, 102, 104, 105]; myData.forEach(async data => { let response = awai ...

webpack - compile one TypeScript file separately (2 actions)

In summary... When my Vue files are combined with background.ts, webpack processes them to create bundled vue files along with background.js I'm unable to run the background.js script I expected background.js to only contain "console.log(' ...

Tips for creating an array that aligns with the keys of a type in TypeScript

Currently, I am utilizing the Kysely SQL builder for JS based on Vercel's recommendation, despite the limited documentation and community support. This SQL builder is fully typed, allowing you to create a db object with a schema that recognizes table ...

Is there an array containing unique DateTime strings?

I am dealing with an Array<object> containing n objects of a specific type. { name: 'random', startDate: '2017-11-10 09:00', endDate: '2017-11-23 11:00' } My goal is to filter this array before rendering the resu ...

Identify all elements that include the designated text within an SVG element

I want to target all elements that have a specific text within an SVG tag. For example, you can use the following code snippet: [...document.querySelectorAll("*")].filter(e => e.childNodes && [...e.childNodes].find(n => n.nodeValue ...

The custom validation feature in Angular 4 is failing to function as expected

Currently, my focus is on Angular 4 where I have developed a custom validator for checking CGPA values (to ensure it is between 2.0 and 4.0). Although the predefined `Validators.required` works fine, my custom validator seems to be not triggering as expect ...

Is it possible to reference the prior value of a computed Angular signal in any way?

Is it possible to dynamically add new values from signal A to the existing values in signal B, similar to how the scan operator works in RxJS? I am looking for something along the lines of signalB = computed((value) => [...value, signalA()]). Any sugg ...

"Utilizing provideMockStore in NgRx 8 for setting the state of a specific State Slice

I have been working on testing a smart component for my NgRx implementation, and the test setup looks like this: describe( 'Component', () => { let store: MockStore<State>; beforeEach( async( () => { TestBed.configureTesting ...