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
393 views
in Technique[技术] by (71.8m points)

Is there a way to enforce method return types on Typescript classes via a tslint rule?

I've read the tslint rules here and while it looks like the typedef rule's call-signature option is what I want, it doesn't complain about the lack of a return type.

Anyone know the rule (f one exists) to enforce return types on class methods?

question from:https://stackoverflow.com/questions/42793701/is-there-a-way-to-enforce-method-return-types-on-typescript-classes-via-a-tslint

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

1 Answer

0 votes
by (71.8m points)

Turns out this can be done via:

"typedef": [
  true,
  "call-signature",
  "property-declaration"
]

More info: https://palantir.github.io/tslint/rules/typedef/


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

...