[Good first issue!] JSDoc TypeScript-compatible types & improving Less maintenance #3786
matthew-dean
started this conversation in
Ideas
Replies: 1 comment
-
cc @iChenLei |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Less historically has not had very good code documentation. If anyone is up for it, you could improve the longevity and maintainability of Less by doing the following:
Add a JSDoc TypeScript-compatible block above function and variable declarations. See: https://www.typescriptlang.org/docs/handbook/intro-to-js-ts.html
Taking a file at a time, correctly document the types for each function and variable. If you're not sure from the code what the type is, one way to determine it is by running Less tests and adding a console.log of the type, either with
typeof
, or, in the case of objects, something likeJSON.stringify
.If possible / necessary, document the intended purpose of a function in the JSDoc block if it's not clear.
Add
"noImplicitAny": true
topackages/less/tsconfig.json
Add
// @ts-check
to the top of your file. Does it pass a TypeScript check?Ideally, this would be done for each file, but even doing this for one file is a valuable contribution.
Additional note: In some cases, such as in the case for types shared amongst multiple
.js
files, it would be fine to create an externaltypes.ts
file (perhapspackages/less/src/types/index.ts
?) that is imported using Import types in JSDoc: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#import-typesBeta Was this translation helpful? Give feedback.
All reactions