Having trouble executing TypeScript code that includes decorators

Each time I attempt to execute the testClass.ts, I encounter an error with these two simple files:

PS C:\Deno\pancakes> deno run testClass.ts
Compile file:///C:/Deno/pancakes/testClass.ts
error: TS1219 [ERROR]: Experimental support for decorators is a feature that may change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.
    name: string;
    ~~~~
    at file:///C:/Deno/pancakes/testClass.ts:5:5

testClass.ts

import { notNull } from "./mod.ts";

class Person {
    @notNull
    name: string;

    constructor(name: string) {
        this.name = name;
    }
}

let newPerson = new Person("");

mod.ts

export function notNull(target: any, propertyKey: string) {
    console.log(target, propertyKey);
}

I've tried enabling the experimentalDecorators option in VSCode and creating the tsconfig.json, but still cannot get the program to run. There are no errors showing up in VSCode, yet I can't execute it.

Edit: this is what happens

Answer №1

To utilize deno, it is important to explicitly define your tsconfig settings.

> deno run -c tsconfig.json testClass.ts

Explore more on custom TypeScript compiler options here

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

Struggling to retrieve data with arrow function in Vue

I'm currently learning Vue and facing an issue with fetching data from an API to my component. I have a service class that successfully retrieves data from the API, as the API itself is working fine. Here's the code snippet: import IReview from & ...

There seems to be a contradiction in my code - I am returning a Promise but TypeScript is throwing an error saying that the

I currently have a function that retrieves a bot's inventory on the Frontend fetchBotInventory() { this.socket.emit('fetch bot inv'); this.socket.on('bot inv', (botInventory) => { return new Promise((resolve, re ...

Issue "Value of type '{}' cannot be assigned to parameter of type 'T | (() => T)'" encountered within a React component containing a type parameter

Currently, I am attempting to achieve the following: function SomeComponent<T>({ children }: PropsType) { const [configuration, setConfiguration] = useState<T>({}) } However, I am encountering this issue: The argument of type '{}&apos ...

Using TypeScript to automatically deduce the output type of a function by analyzing the recursive input type

I am currently working on developing an ORM for a graph database using TypeScript. Specifically, I am focusing on enhancing the "find" method to retrieve a list of a specific entity. The goal is to allow the function to accept a structure detailing the joi ...

Adjust the color of the IText element on a Fabric.JS canvas (utilizing React and typescript)

I have an input with the type=color attribute positioned outside of a Canvas. Inside the canvas, there are one or more IText objects along with other elements. My goal is to "change the color of selected text objects when the input value changes". Incorpo ...

Ramda in Typescript has unexpectedly encountered an error

While building my project (reactjs starter + typescript) on production, I encountered this TypeScript error: TypeScript error: Argument of type '<T>(list: readonly Record<"dataField", T>[]) => T[]' is not assignable to parameter.. ...

Can you explain the mechanics behind Angular Component CSS encapsulation?

Is it possible to avoid CSS conflicts when using multiple style sheets? Consider Style 1: .heading { color: green; } And Style 2: .heading { color: blue; } If these two styles are applied in different views and rendered on a layout as a Partial Vi ...

The required dependencies for google-chart-angular are not found

I have been trying to set up google-chart-angular in my Angular project by following the steps outlined in this tutorial. I have also added GoogleChartsModule to my app.module.ts file. Although I believe everything is set up correctly, when I try to run t ...

RxJs encountered an error due to an invalid module name when the map option was utilized in augmentation

I've been encountering the error displayed in the map.d.ts file (see first image). As a result, my intellisense isn't functioning properly as shown in the second image. Your assistance in resolving this problem would be greatly appreciated. htt ...

Comparing angular2/core and @angular/core: What sets them apart?

Maybe this is a silly question, but I've noticed that there are multiple instances of import {Component} from 'angular2/core' and import {Component} from '@angular/core' However, I can't seem to grasp when to use one ove ...

What strategies can I implement to streamline the use of these functions instead of creating a separate one for each textfield

Currently, I am learning how to use spfx with SPO (SharePoint Online). In my form, there are multiple text fields that need to be handled. I have two class components named A and B. Whenever a textfield in component B is typed into, a function sends the in ...

What is the best way to ensure an observable has been updated before proceeding with additional code execution?

Is an observable the best choice for providing live updates of a variable's value to another class? I have a loop in my service class that looks like this: elements.forEach(element => { doStuff(); this.numberSubject.next(valueFromDoStuff); }) ...

Guidelines for properly storing user data post-login in Nuxt3

When a user logs in, I need to store their data for future use. I have middleware set up on the "/page" page to check if the user is logged in, and if so, it allows them through. However, I notice that the user data is lost when the page is refreshed. In t ...

The upcoming development does not involve creating an entire HTML webpage using on-demand static site generation (SS

I’m encountering a problem when utilizing getStaticPaths and getStaticProps to create an on-demand SSG for a sharing page. My setup involves Next v12.1.0 and React 17.0.2. After building a specific /[id] page, I can retrieve the data but the HTML output ...

Hidden input fields do not get populated by Angular submit prior to submission

I am in the process of implementing a login feature in Angular that supports multiple providers. However, I have encountered an issue with submitting the form as the loginProvider value is not being sent to the server. Below is the structure of my form: &l ...

A guide on renewing authentication tokens in the Nestjs framework

import { ExtractJwt, Strategy } from 'passport-jwt'; import { AuthService } from './auth.service'; import { PassportStrategy } from '@nestjs/passport'; import { Injectable, UnauthorizedException } from '@nestjs/common&apo ...

Encountering a problem when attempting to save time without a timezone in PostgreSQL

I'm experiencing a problem inserting a time value into the startTime field of my entity in PostgreSQL. Here is the relevant code snippet: @Property({ type: 'time' }) startTime!: Date; Within my service function: await this.persistAndFlush(c ...

The value of "metadata" is not a valid export entry for Next.js

After I installed Next.js 14 with TypeScript, I encountered an error related to my metadata type definition. import type { Metadata } from "next"; export const metadata: Metadata = { title: "next app", description: "next app 1 ...

The 'unsubscribe' property is not found on the 'Observable<DataSnapshot>' type

I am facing a typescript error in my code, specifically in the tslint plugin of Atom editor. Unfortunately, I am struggling to determine how to correctly set the type. Error message: https://i.sstatic.net/VU3ee.png Here is the code snippet for the chat c ...

Troubleshooting problem with Angular Click Outside Directive and unexpected extra click event issue

The challenge I'm facing involves implementing a custom Click Outside Directive for closing modal dialogs, notifications, popovers, and other 'popups' triggered by various actions. One specific issue is that when using the directive with pop ...