Can't Run Typescript Code with Decorators

I have this two simple files but every time I try to run the testClass.ts I get this error:

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 is subject to 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 have already enable the experimentalDecorators option in VSCode, create the tsconfig.json and everything but still can't run the program. I't doesn't show the error in VSCode but can't run.

Edit: this is what happens

1 Answer

With deno you need to explicitly specify your tsconfig,

> deno run -c tsconfig.json testClass.ts
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest