You can use the body of an interface as a type literal:
function Thing(test: { hello: string; }) {
test.hello // works
test.bob // I want this to fail
}
is equivalent to
interface ITest {
hello: string;
}
function Thing(test: ITest) {
test.hello // works
test.bob // I want this to fail
}
Just don't forget the ;
at the end of each member.
There is no syntax for naming or referring to inferred types. The closest you can get is using interfaces or type-literals for the members you are going to use. Interfaces and type-literals will match whatever type which at least has the defined members. "Duck-typing"