Recessions often have warning signs before they occur. And one such warning flashed last week. The curve for five-year and 30-year U.S. Treasury bond yields inverted with the longer-term yield falling lower than the shorter-term yield. 

Such inverted yield curves hint that investors are worried about the prospects for the U.S. economy. Granted, economists monitor the relationship between the two-year Treasury yield and 10-year yield more closely. That yield curve also briefly inverted last Tuesday before flattening out then inverted again on Thursday.

Inverted yield curves don't always mean that a recession is coming. But they frequently do. If that's the case this time around, here are three stocks to buy to be prepared.

A person with a concerned expression looking at a laptop.

Image source: Getty Images.

1. Dollar General

Consumers tighten their purse strings during economic downturns. That's bad for many retailers. However, discount retail chains can experience increased business. That's why Dollar General (DG -0.76%) could be a solid stock to own if a recession is on the way.

Dollar General operates 18,130 stores and counting across 46 U.S. states. The company plans to open 1,110 new stores in 2022. It also expects to remodel 1,750 existing stores and relocate another 120 stores.

The discount retailer has been in business for more than 80 years. It has weathered plenty of recessions during that period. 

Dollar General CEO Todd Vasos noted in the company's Q4 conference call a few weeks ago that roughly three-quarters of the U.S. population now has a Dollar General store within five miles of their home. If gas prices remain high during the next recession, this convenience could especially work to Dollar General's benefit.

2. Easterly Government Properties

Many, if not most, businesses would likely be negatively impacted if a recession hits. However, Easterly Government Properties (DEA 0.60%) shouldn't see its revenue affected at all.

Easterly is a real estate investment trust (REIT) that focuses on leasing properties to U.S. federal government agencies. It owns 89 properties with a weighted-average remaining lease term of 9.7 years.

The company often states that its cash flow is "backed by the full faith and credit of the U.S. government." That's not an exaggeration. There's arguably no safer and more dependable tenant in the world than Uncle Sam.

Sure, Easterly's share price isn't completely immune to declining during a recession. However, its stock would likely fall less than most others would. And even if it dips, investors can count on a dividend that currently yields more than 5% as a nice cushion.

3. Vertex Pharmaceuticals

Drugmakers usually don't have to worry much about sales declines during recessions. That's especially true for a company that dominates the market in a given indication. Vertex Pharmaceuticals (VRTX 0.78%) is great example. The big biotech markets the only approved drugs that treat the underlying cause of cystic fibrosis (CF).

Vertex's CF revenue should increase regardless of what happens with the economy. The  company continues to win additional regulatory approvals for younger age groups. It also keeps picking up key reimbursement deals in Europe.

But the main reason why the stock could rise is that Vertex has potential catalysts on the way that could dramatically improve its growth prospects. Vertex and its partner, CRISPR Therapeutics, should report late-stage results this year for gene-editing therapy CTX001 that could pave the way for regulatory filings by the end of 2022. Vertex thinks CTX001 has a multibillion-dollar opportunity.

Vertex also has a late-stage program targeting APOL1-mediated kidney disease. This indication could open up a bigger market than the company has in CF. The biotech plans to advance its non-opioid pain drug VX-548 into late-stage testing this year as well after recently reporting positive results from a phase 2 study.