meta_pixel
Tapesearch Logo
Log in
Syntax - Tasty Web Development Treats

JS Fundamentals - Decorators

Syntax - Tasty Web Development Treats

Wes Bos

Tech News, News, Technology

4.91.2K Ratings

🗓️ 14 August 2023

⏱️ 22 minutes

🧾️ Download transcript

Summary

In this Hasty Treat, Scott and Wes talk about whether decorators are finally here, what the uses cases are for decorators, how to define a decorator, and what auto accessor is. Show Notes 00:25 Welcome 01:00 Are decorators finally here? TC39 proposal How this compares to other versions of decorators 06:47 What are use cases for decorators? 10:55 How do you define a decorator? 14:20 Auto Accessor on classes @loggged class C {} on fields class C { @logged x = 1; } Auto Accessor class C { accessor x = 1; } sugar for below class C { #x = 1; // # means private get x() { return this.#x; } set x(val) { this.#x = val; } } Can be decorated and decorator can return new get and set and init functions function logged(value, { kind, name }) { if (kind === "accessor") { let { get, set } = value; return { get() { console.log(`getting ${name}`); return get.call(this); }, set(val) { console.log(`setting ${name} to ${val}`); return set.call(this, val); }, init(initialValue) { console.log(`initializing ${name} with value ${initialValue}`); return initialValue; } }; } // ... } Tweet us your tasty treats Scott’s Instagram LevelUpTutorials Instagram Wes’ Instagram Wes’ Twitter Wes’ Facebook Scott’s Twitter Make sure to include @SyntaxFM in your tweets Wes Bos on Bluesky Scott on Bluesky Syntax on Bluesky

Transcript

Click on a timestamp to play from that location

0:00.0

Monday. Monday. Day. Open wide dev fans. Get ready to stuff your face with Javascript CSS.

0:08.2

Node modules. Barbecue tips. Get workflow. Break dancing. Soft skills. Web development.

0:12.8

The hastiest. The craziest. The tastiest. Web development treats. Coming in hot.

0:18.4

Here is Wes Barakuda. Boss. And Scott El Torro Lugo. Tolinsky.

0:25.0

Welcome to syntax on this Monday hasty treat. We're going to be talking about decorators.

0:32.7

We're going to be diving into the current status of decorators in Javascript.

0:37.7

We're going to be talking about what they are, how to use them, and maybe some of the finer

0:41.9

points and maybe even future points of what decorators behold to us. My name is Scott

0:48.1

Elinsky. I'm a developer from Denver. And with me, it's always his west boss.

0:51.5

Hey, everybody. Excited to talk about decorators. Finally, I feel like we've mentioned them on

0:57.5

the show for years and years and years. And they are. Is it safe to say they are finally here?

1:03.3

I mean, they're here ish. And so the current status of decorators is they are currently in stage 3.

1:10.8

Firefox is implementing them as we speak. There is an open issue about it. But I believe before

1:17.7

they go to stage 4, they need to have two independent browsers implementing them. So as far as

1:24.5

I know, I haven't seen anything about Chromium or Safari implementing these. So we will see

1:33.2

when decorators will arrive. But you can use decorators in many senses. Many times people are using

1:40.4

different plugin systems, whether it's Babel or whatever. And now the actual decorator spec will

1:45.2

differ. Well, maybe not quite a bit differs a bit from the one that's available in TypeScript

1:53.0

or the one that's available in Babel or any of the means in which you try to use decorators.

1:58.0

But we're going to be mostly talking about class decorators because that is what is coming to

2:03.5

the browser in stage 3. Are they different than the TypeScript versions different than the

2:10.3

the spec ones? Because I know there was TypeScript decorators for a long time. And then TypeScript

...

Please login to see the full transcript.

Disclaimer: The podcast and artwork embedded on this page are from Wes Bos, and are the property of its owner and not affiliated with or endorsed by Tapesearch.

Generated transcripts are the property of Wes Bos and are distributed freely under the Fair Use doctrine. Transcripts generated by Tapesearch are not guaranteed to be accurate.

Copyright © Tapesearch 2026.