Teddy DeVita, his friends said yesterday, was, in many respects, a typical 17-year-old youth. He liked Shakespeare and "Star Trek," played electric guitar, grew a beard, drank too much champagne last New Year's Eve and bickered with his kid sister.

Only one thing set Teddy apart from his peers.

Because of a rare bone marrow disease that eliminated his body's resistance to infection, he had been confined to a 5-foot-square, germ-free hospital cubicle in Bethesda for the last eight years. There, at the National Institutes of Health where his father heads the National Cancer Institute, Teddy DeVita died early Tuesday morning of complications caused by repeated blood transfusions.

DeVita developed aplastic anemia at age 9, and for the next eight years could not touch or be touched by anyone. The usually fatal disease affects the body's bone marrow, preventing it from producing the white cells that fight infection, red cells that transport oxygen to the tissues and platelets for clotting.

Repeated blood transfusions and the "laminar flow" isolation room, where vistors were separated from him by glass barriers, kept Teddy DeVita alive.

NIH officials said yesterday the Bethesda teen-ager made medical history by becoming the longest surviving patient with aplastic anemia. He is also believed to have spent more time in a sterile, germ-free atmosphere than any other person.

"It's absolutely remarkable," said Dr. Philip, DeVita's physician since 1972. "He was able to adapt so well to that environment. To me, he's an inspiration."

DeVita's environment, one of eight sterile isolation rooms set up by the National Cancer Institute for patients prone to infection, was kept free of harmful bacteria by special filters that forced clean air into the room and out again through an open doorway.

At the time of his death, young DeVita's living quarters boasted a stereo set, television, books, records, a small recording studio, two Les Paul electric guitars, a telephone, a commode and shower and a specially designed helmet that allowed the dark-haired teen-ager to make short trips outside his tiny cubicle. He often went to rock concerts at the Capital Centre, friends said yesterday, where he sat in a special VIP "Sky Suite." And three years ago, he attended the Star Trek convention at a local hotel, wearing a special spacesuit that kept him germ-free.

"He was kinda shy," said Mark Cherry, a fellow musician and friend. "He never liked going out in the suit."

But the youth never thought of himself as a prisoner.

"He controlled his environment," said Kevin James, a local disc jokey who befriended Teddy five years ago. "He didn't want pity. I never heard him complain once."

Said Cherry, "Teddy just clung on to hope. He was a real fighter."

For the past eight years, DeVita's food had to be of "low germ burden," which meant little or no fresh fruits. Only oranges and bananas, if they were boiled, were allowed. The rest of his food had to be cooked for longer than normal time periods.

"Over the years, he matured in that room," his grandfather, Jim Lipscomb of Alexandria, said yesterday. "We saw him grow from a child to a young man. His interests changed from toys to electrical gadgets, to guitars. He could beat his father at chess. And once, he had a CB radio set up in his room."

His parents, Lipscomb said yesterday, "did a magnificant job looking after him. They had a very close relationship, one of love and understanding." His parents declined to be interviewed.

"It's a tragic thing," Lipscomb added, "but they all realized he might not get out."

The son of nationally known cancer specialist Dr. Vincent T. DeVita Jr., young Teddy had just returned from a trip to the West Coast with his family in the fall of 1972 when he fell ill.

When he was admitted to NIH on Sept. 15 of that year, Dr. Arthur S. Levine, chief of the children's cancer treatment unit, said, "Teddy would either recover or die."

The boy lived in the tiny room for nearly four years, out of the public eye, until 1976, when an anonymous letter to NIH accused the federal facility of giving special care to an NIH offical's son, while denying the same care to another child who died "because his parents were of lesser influence."

The cost of young DeVita's medical care at the time was estimated to be $300 a day. Although NIH officials declined to state the entire cost to the government over eight years, it is estimated to be nearly $1 million.

"We would have accepted Teddy whether he was Dr. DeVita's son or not," said Dr. Philip Pizzo, senior investigator for the pediatric oncology branch at NIH and the youth's physician. "We were very interested in his case for the research benefits, which have been enormous. We had never before studied someone with severe bone-marrow failure."

Although bone-marrow transplants are often successful among family members, Pizzo said yesterday, the youth's younger sister Elizabeth 14, has a different type of marrow and was unable to become a donor.

"As a family," Lipscomb, the youth's grandfather, recalled yesterday, "they were particularly well adjusted. They talked on an adult level."

Teddy's mother would visit her son twice daily, said Dr. Pizzo, and nurses would often find his father, Dr. DeVita, working in Teddy's room just outside the cubicle late at night.

The youth scored in the top 99 percentile on his college board exams, Pizzo said yesterday, and was due to graduate from high school this June. He had been tutored through the Montgomery County school system and was planning to take college courses next year.

"At first he wanted to be an archeologist," recalled Dr. Pizzo. "Recently, he was interested in electronics. And he was a real Shakespeare freak."

But two weeks ago, young DeVita began experiencing cardiac problems. The repeated blood transfusions had caused a buildup of iron in the teenager's heart, a medical risk of which the family was aware.

"The thing that killed him did it so suddenly," Dr. Pizzo said. "I think, in the end, he knew he was dying. But he continued to fight."

Dr. Pizzo said that at first, when Teddy was a youngster, he resented the confinement and threw "temper tantrums." But as the years went by, he thought less and less of getting out, and concentrated more on living within his sterile sanctuary.

"The message he gave to me," Pizzo said, "was that initially he had hoped for getting out. But now, it seemed that he set his sights on living day to day. In order to deal with it, he stopped thinking about it."