This is the way. Provide value on an ML-adjacent team and expand your scope over time.
One thing to watch out for is being too far from ML at an ML-heavy company. Those places often have plenty of devs doing frontend work, integrations, etc. but those roles are not so different from similar roles at non-ML companies. Being awesome at typescript isn't going to help you shift to ML work. You want to be as close to the ML folks as possible: data engineering, data science, ML platform, etc. A common theme there is python, so get very comfortable with the language and ecosystem.