Taiwanese President Tsai Ing-wen waves to the crowd on May 20, 2016 in Taipei, Taiwan.

Chinese state media threatened on Friday that the country could go to war over Taiwan if the United States passes into law a bill promoting closer U.S. ties with the self-ruled island that China claims as its own.

The legislation, which only needs President Donald Trump's signature to become law, says it should be U.S. policy to allow officials at all levels to travel to Taiwan to meet their Taiwanese counterparts, permit high-level Taiwanese officials to enter the United States "under respectful conditions" and meet with U.S. officials.

Beijing considers democratic Taiwan to be a wayward province and integral part of "one China", ineligible for state-to-state relations, and has never renounced the use of force to bring the island under its control.

In a strongly-worded editorial, the official China Daily said that if the bill becomes law, it will only encourage Taiwan President Tsai Ing-wen to further assert the island's sovereignty.

"Which, if she persisted, would lead to the inevitable consequence of triggering the Anti Secession Law that allows Beijing to use force to prevent the island from seceding," the paper said, referring to a Chinese law passed in 2005.

"Since the U.S. is bound by domestic law to act on behalf of the island in that instance, it would only give substance to the observation that the descent into hell is easy."

China's hostility towards Taiwan has risen since Tsai from the pro independence Democratic Progressive Party won the presidential elections in 2016.

China suspects Tsai wants to push for formal independence, a red line for Communist Party leaders in Beijing, though she has said she wants to maintain the status quo and is committed to ensuring peace.

Taiwan has welcomed the U.S. legislation.

In a second editorial, the widely-read state-run Global Times tabloid said China could "make targeted measures against pro-independence forces in Taiwan".

"Militarily, the strength of the People's Liberation Army has fundamentally changed the military and political situation across the Straits," it said, talking about the narrow waterway that separates Taiwan from its giant neighbour.

"Thanks to its rapid growth, the Chinese mainland is now granted unparalleled strategic initiative across the Taiwan Straits."

China has dramatically upped its military presence around Taiwan. China's air force has carried out 16 rounds of exercises close to Taiwan in the last year or so, said Taiwan's defence ministry in late December, warning that China's military threat was growing by the day.

The United States has no formal ties with Taiwan but is bound by law to help it defend itself and is the island's main source of arms. China regularly says Taiwan is the most sensitive issue in its ties with Washington.