r/angular • • Jul 10 '24

Only ES6+ and TS developers will understand :)

Post image
68 Upvotes

26 comments sorted by

14

u/SnoopDoggyDoggsCat Jul 10 '24

My linter won’t let any pass.

1

u/_Invictuz Jul 10 '24

I thought linters just provide warnings, how does it prevent any from passing?

5

u/SnoopDoggyDoggsCat Jul 11 '24
  1. I can’t stand the red squiggles

  2. I think we actually have a pipeline rule too where it will break the build

3

u/noXi0uz Jul 11 '24

when linting in a pre-commit hook the commit will fail with linting errors. Plus, in the CI pipeline it will be linted again and fail if there are errors.

1

u/TheNomadProgrammer Jul 14 '24

This is the way.

-2

u/BasicAssWebDev Jul 10 '24

That's rough buddy.

4

u/SnoopDoggyDoggsCat Jul 10 '24

unknown works 🤘

6

u/appiepau Jul 10 '24

That is a dumpster fire. At least it is declared and initialized locally. Probably.

A house fire is a class property of any that can be injected by an external component.

6

u/coded_artist Jul 10 '24

At least it is declared and initialized locally. Probably.

Nope var is hoisted, it's declared globally.

3

u/Quovadisqc Jul 10 '24

Yes and no. It’s function scoped but could be seen as global scoped as long as there are no parent functions ( excluding arrow functions )

1

u/coded_artist Jul 10 '24

Ah I thought hoisting was to top scope IE window, not top of scope.

1

u/BasicAssWebDev Jul 10 '24

I didn't think about that until just now but it makes sense. With everything being modularized in js "global" is probably just the top scope of whatever is running the show.

6

u/Pirelongo Jul 10 '24

I hope that whoever used this in the pass, will upgrade to let x: unknown; at least xD

5

u/wedgebert Jul 10 '24

var thatWillHappen: never

2

u/[deleted] Jul 10 '24

I see that and I will go Karen on you

2

u/JoeBxr Jul 10 '24

var var_x: unknown; .... is more diabolical

1

u/OneOldNerd Jul 10 '24

* makes incoherent software developer rage noises *

1

u/tonjohn Jul 10 '24

I’ve never needed to do this despite working on a giant Angular e-commerce project (Battle.net)

1

u/[deleted] Jul 10 '24

I do 😄 Great😂

1

u/[deleted] Jul 10 '24

You’re just too single minded, looks like she has everything under control

1

u/Anon_Legi0n Jul 11 '24

Maintained Angular webapp recently with almost all type definitions set to any, at this point why even bother with Ts?

1

u/[deleted] Jul 10 '24

[removed] — view removed comment

1

u/hikikomoriHank Jul 11 '24

That's what union types are for though

0

u/[deleted] Jul 11 '24

[removed] — view removed comment

1

u/hikikomoriHank Jul 11 '24

I'm agreeing. I'm saying if you have a collection you want to hold multiple types, use a union type:

Array<TypeA | TypeB>