Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
257 views
in Technique[技术] by (71.8m points)

typescript - Assert class has only properties of an interface

How to make sure a class implements an interface, and has no properties besides those needed to implement that interface?

interface A {
  a: string;
}

class Klass implements A {
  a: string; // make sure Klass has a:string;
  b: number; //this should throw - make sure it implements ONLY interface A
}
question from:https://stackoverflow.com/questions/65871292/assert-class-has-only-properties-of-an-interface

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...