Open ljharb opened 6 months ago
Are these hand written or generated from JSDoc ? It's unclear to me. Either way looks reasonable to me.
Hand-written.
lib/test.d.ts
[error] 112-112: Don't use 'Function' as a type. Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs. (lint/complexity/noBannedTypes) --- [error] 126-126: Don't use 'Function' as a type. Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs. (lint/complexity/noBannedTypes) --- [error] 192-192: Don't use '{}' as a type. Prefer explicitly define the object shape. '{}' means "any non-nullable value". (lint/complexity/noBannedTypes) --- [error] 198-198: Don't use '{}' as a type. Prefer explicitly define the object shape. '{}' means "any non-nullable value". (lint/complexity/noBannedTypes)
lib/test.d.ts (2)
`210-210`: **Avoid using `{}` as a type.** The use of `{}` as a type is discouraged. Consider defining a specific object shape instead. Apply this diff to define a specific object shape: ```diff - export type RestoreFunction = Exclude, undefined>; + export type RestoreFunction = () => void; ``` > Likely invalid or redundant comment. --- `38-38`: **Avoid using `Function` as a type.** The use of `Function` as a type is discouraged. Consider defining a specific function type instead. Apply this diff to define a specific function type: ```diff - /** @typedef {Function} Callback */ + /** @typedef {(...args: unknown[]) => unknown} Callback */ ``` > Likely invalid or redundant comment. lib/test.js (1)
Line range hint `83-123`: **Constructor implementation is appropriate.** The constructor correctly initializes properties and binds methods. Ensure all methods are correctly bound to the instance. Run the following script to verify method bindings:Verification successful
--- **Method bindings are correctly implemented.** The `Test` constructor iterates over its properties and binds functions using `callBind`, confirming that method bindings are handled as expected. The use of `@ts-expect-error` is acknowledged in the code. No further issues were found. - Method bindings are correctly handled in lines 121-126.Scripts executed
The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Description: Verify all methods are correctly bound to the `Test` instance. # Test: Search for method bindings. Expect: All instance methods are bound. rg --type js -A 5 $'this[prop] = callBind(this[prop], this)' ``` Length of output: 61 --- Script: ```shell #!/bin/bash # Description: Search for method definitions within the `Test` class and check for bindings. # Find the `Test` constructor and methods within the same file. ast-grep --lang javascript --pattern $'function Test($_, $_, $_) { $$$ this.$_ = $_; $$$ }' ``` Length of output: 1727
Thanks, I've updated the PR and gotten it down to 4 errors (i swear it was at zero when I put up the PR :-p)
I'd love to get suggestions for those.
Oop, sorry for taking so long - I'd added this tab on my phone and forgot about it 😅. Looking now!
it down to 4 errors
On the latest commit I get no errors. So, nicely done! 😄
New dependencies detected. Learn more about Socket for GitHub ↗︎
Normally I'd just push this commit up and publish it, but since
@types/tape
already exists, I thought this was worth a PR so others can double check me.