Reputation: 1041
Is there away (annotation or any other method) to hide methods from Intellisense.
Upvotes: 2
Views: 1675
Reputation: 251172
You can use an interface to describe a reduced contract. Anything not described in the interface would effectively be hidden from auto-complete even though it is available on the class. This gives you the flexibility to decide when you want access to the property.
interface IReducedInterface {
name: string;
}
class ExpandedClass implements IReducedInterface {
public name: string;
public hideFromIntellisense: string;
}
var example: IReducedInterface = new ExpandedClass();
If you type example.
it will suggest name
but not hideFromIntellisense
.
You don't need to explicitly implement IReducedInterface
as TypeScript is structurally typed.
Upvotes: 4
Reputation: 276225
I don't recommend this. But you can always walk into JavaScript, and typescript would not know:
class Test{
member:string;
visible(){
this.member='visible';
}
}
(<any>Test.prototype).notvisible = function(){ this.member ='notvisible'; }
Alternatively you could mark the function as private.
class Test{
member:string;
visible(){
this.member='visible';
}
private notvisible(){
this.member ='notvisible';
}
}
Upvotes: 0