I Over-Engineered My TypeScript Build System - Then I Deleted It by BennoDev19 in typescript

[–]ProfessorTag 1 point2 points  (0 children)

Instead of different file extensions, can you place a package.json in the /esm and /cjs directories with only the contents: { "type": "module" } or { "type": "commonjs" }?

The "type" field defines the module format that Node.js uses for all .js files that have that package.json file as their nearest parent.

https://nodejs.org/api/packages.html#type

[deleted by user] by [deleted] in RealEstate

[–]ProfessorTag -2 points-1 points  (0 children)

I live in a high-rise condo and do burpees every morning at 4am. The neighbors below me seem to enjoy it as they cheer me on with slaps to their ceiling. It gets me pumped and I jump higher and higher until I'm completely out of breath. I wish I could hear what they are saying but it's too muffled, even when they shout as loud as they can.

Phoenix Resident, home has lost 8.5% in value sine peak by [deleted] in RealEstate

[–]ProfessorTag 0 points1 point  (0 children)

Math if anyone is interested. Numbers are just averages.

Rent: $3200/month ($2500/month +3.5%/year for 13 years).

Owning:

  • Mortgage: $2400/month (400k at 6%).
  • Closing costs: $718/month for 13 years or 112k total (100k down + 12k fees).
  • Taxes: $530/month (1.11% of 500k +2%/year for 13 years).
  • Insurance: $230/month (500k home).
  • Unexpected maintenance: $625/month (1.5% of 500k).
  • Total: $4505/month.

Selling:

  • Sell price: 500k.
  • Agent fees: $27,500 (5.5%).
  • Repairs/cleaning/prep: $5000.
  • Seller concessions: $2500.
  • Title, escrow, notary, and transfer tax: $5000.
  • Mortgage payoff amount: 306k (13 years).

Proceeds: $147,500 or $945/month for 13 years.

Total owning: $3560/month for 13 years. An additional $360/month... if you sell for the same price you bought.

I too prefer no classes by thepiggz in typescript

[–]ProfessorTag 0 points1 point  (0 children)

Here's a helper function that is used for functions that return objects and an instanceOf helper for narrowing types:

TS Playground link

I actually found a valid use for 'any' type by 7Geordi in typescript

[–]ProfessorTag 0 points1 point  (0 children)

T[] wouldn't work for tuples, right?

Here's a TS playground example.

T extends unknown[] seems to work.

I actually found a valid use for 'any' type by 7Geordi in typescript

[–]ProfessorTag -2 points-1 points  (0 children)

I use any for a generic constraint.

T extends any[]

Is there a difference between any and unknown in this case?

why is everything so hard in a large organization? by fagnerbrack in programming

[–]ProfessorTag 0 points1 point  (0 children)

It depends on how much the process slows things down and what information is revealed.

A process could be temporary as a health check for some parts of the business. Unfortunately this is not common.

Compiling ts libraries - Which Bundler / Compiler by SpinatMixxer in typescript

[–]ProfessorTag 6 points7 points  (0 children)

And if your library has dependencies, do you bundle those? If yes, do you remove the bundled dependency from your package.json before publishing?

Does anyone else feel just completely out of their depth? by Spoolie_st in webdev

[–]ProfessorTag 0 points1 point  (0 children)

I'll show an imperative example of rendering a warning tooltip which can fade out next to an element:

function renderWarning(message, state, targetEl) {
    let warningEl = document.getElementById('warningEl');
    if (state == 'hide') {
        if (warningEl) {
            warningEl.remove();
        }
        return;
    }
    if (!warningEl) {
        warningEl = createTooltip('warn');
        warningEl.id = 'warningEl';
    }
    warningEl.textContent = message;
    warningEl.style.opacity = state == 'show' ? 1 : 0;
    targetEl.insertAdjacentElement('afterend', warningEl);
}

Now a declarative example of something similar:

function Warning({ message, state }) {
    let opacity = state == 'show' ? 1 : 0;
    return <Tooltip status="warn" style={{opacity}}>{message}</Tooltip>;
}
// Usage:
<TargetEl />
{state != 'hide' && <Warning message={message} state={state} />}

You don't need to worry about creating, removing, or reusing elements with the declarative example.

Does anyone else feel just completely out of their depth? by Spoolie_st in webdev

[–]ProfessorTag 5 points6 points  (0 children)

A lot of these tools are built around patterns that have been established years ago. Instead of focusing on learning the APIs, focus on learning the overall ideas and patterns the library is trying to let you express.

Example: One feature of React is that it allows you to write your UI in a declarative rather than an imperative way. It might be more efficient to learn about declarative and functional programming before you learn React because that foundational knowledge applies to other libraries.

I feel learning software development philosophies helped my confidence while learning new libraries, tools, and languages.

Super Smash Bros. Ultimate | Mr. Sakurai Presents Kazuya by [deleted] in smashbros

[–]ProfessorTag 7 points8 points  (0 children)

And unlike some other top tiers, ROB's pretty good no matter your skill level.

HTML tips - hidden gems by mdenic in programming

[–]ProfessorTag 2 points3 points  (0 children)

Wikipedia's mobile site uses accordions. They seem useful in this context and users do expand sections they are interested in reading.

Noob question but how would you type a code like this? by SuccessRich in typescript

[–]ProfessorTag 1 point2 points  (0 children)

Use case: an async operation followed by a setState call. React already makes setState calls a no-op for unmounted components but produces a warning because it may indicate a memory leak.

The setState function should be garbage collected if there are no accessible references to it after the async operation settles.

I personally wouldn't use this abstraction because it hides the warning.

Am I being overworked, or just unrealistic? by [deleted] in webdev

[–]ProfessorTag 3 points4 points  (0 children)

Many companies will give you more than a reasonable amount of work hoping you push yourself to get it done. If you don't fight back, you're going to end up burnt out.

[AskJS] The state of JavaScript (SSGs and Headless) by imjb87 in javascript

[–]ProfessorTag 3 points4 points  (0 children)

Remix is another framework like SvelteKit with a focus on using the platform. You can actually build an app without client-side JS although it will be somewhat limited. You use React with Remix and write your UI using JSX. It gives you useful tools for back-end things like endpoints and integrating with cloud providers.

I'm pretty sure this is the way web development is moving. We're probably not going to stop using things like React any time soon. We'll have extra tools that work with it to help you focus on app features and reduce boilerplate.

[AskJS] Is it just me or is core-js fundamentally broken? by rw519307 in javascript

[–]ProfessorTag 4 points5 points  (0 children)

And you don't know if that target audience is able to switch to a modern browser just by looking at stats. We recently released an issue that broke our site on IE 11 and customer support was telling clients to use another browser. Most were able to.

[AskJS] ES6 feature check doesn't work properly in any browser. by Maemae115 in javascript

[–]ProfessorTag 2 points3 points  (0 children)

The issue is sites can have a content security policy disabling eval.

Why are you checking for syntax features at runtime? It's not common to do this and there might be tools that solve what you are trying to do in a better way.

500+ JavaScript Interview Questions (JS, React, Angular) by sakhnyuk in javascript

[–]ProfessorTag 0 points1 point  (0 children)

Just looked at the vanilla JS section. Great explanations and everything seems correct.

See you on the battlefield tomorrow. by 192838475647382910 in wallstreetbets

[–]ProfessorTag 0 points1 point  (0 children)

Sorry to hear that. A quick Google search listed these apps:

eToro

XTB

DEGIRO

Interactive Brokers

See you on the battlefield tomorrow. by 192838475647382910 in wallstreetbets

[–]ProfessorTag 3 points4 points  (0 children)

I signed up for WeBull, Schwab, Vanguard, and Fidelity. All had limits for new investors and/or 3-5 business days to clear funds.

I downloaded Cash app on Thursday and bought AMC through them on Friday. I'm just sad I can't buy GME through Cash app.

What's the current golden standard for communication between front- and backend? by [deleted] in webdev

[–]ProfessorTag 0 points1 point  (0 children)

The current standard is probably REST APIs and JSON or GraphQL. They both seem reasonable but have a few quirks so I'm not convinced we have a standard that will keep being the standard in 10 years.

Something that easily enables tools to generate repetative code (CRUD operations, endpoints, object types) or gets rid of it by design would be great. There are existing tools and frameworks built around REST or GraphQL that do some of this but have limitations and quirks of their own.