lib.es5.d.ts 'thisArg' is referenced directly or indirectly in its own type annotation
$ deno --version
deno 1.6.3 (release, x86_64-apple-darwin)
v8 8.8.294
typescript 4.1.3
I was attempting to import rollup in Deno and getting the following error:
$ deno run rollup.ts
Check file:///Users/craigmorten/git/cmorten/rollup/rollup.ts
error: TS2502
[ERROR]: 'thisArg' is referenced directly or indirectly in its own type annotation.
bind<T>(this: T, thisArg: ThisParameterType<T>): OmitThisParameter<T>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at asset:///lib.es5.d.ts:350:22
Which appears to be a type definitions issue with the CallableFunction bind method definition.
REF: https://github.com/denoland/deno/blob/master/cli/dts/lib.es5.d.ts#L350
Reproduce with:
// mod.ts
import "https://unpkg.com/[email protected]/dist/rollup.browser.js";
And running deno run mod.ts.
Please advise! I'm unclear if the issue is the use of .bind(...) somewhere in the rollup code, or whether the ThisParameterType<T> type needs a fix?
I haven't been able to re-produce it simply, but I believe this is related to a situation where TypeScript type checks JavaScript in situations where it is imported into TypeScript to try to see if it can determine the shape of the export, which triggers a situation where the .bind() statements are becoming self referential in the rollup.js. Looking at the file, there is liberal use of .bind() without any arguments, which I am suspecting is triggering this issue with TypeScript in strict mode.
I am not sure we can fix it. The easiest workaround is to substitute types in lieu of the JavaScript code, to keep the TypeScript compiler from looking at that JavaScript. For example, the following works without errors:
// @deno-types="https://unpkg.com/[email protected]/dist/rollup.d.ts"
import "https://unpkg.com/[email protected]/dist/rollup.browser.js";
Thanks for the prompt reply! You are quite right, I have found providing type definitions resolves the issue nicely - better still when using the ES form for unpkg.
// @deno-types="https://unpkg.com/[email protected]/dist/rollup.d.ts"
import {
rollup,
VERSION,
} from "https://unpkg.com/[email protected]/dist/es/rollup.browser.js";
In the absense of being able to offer a minimal reproduceable example, and the fact that the issue is moot when providing type definitions, happy for you to close the issue.
Have tried to unpick something from the Rollup bundle but it is near unnavigatable with, as you say, liberal use of .bind() - many of which transpire to be custom bind methods defined on classes instead of the builtin.
Yeah, that is part of how it makes it hard to narrow down. I came across it once before in some scenario that I can't remember now. It is hard to narrow down. So let's close it as a design limitation for now, and if any of us can find a small repo, we might be able to bring it up with TypeScript, because ultimately that is where we need to try to fix it.
Re-opening due to #12339
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
I receive this while running:
deno run --allow-read --import-map=https://deno.land/x/[email protected]/import-map-deno.json --allow-net -r https://deno.land/x/[email protected]/src/tests/index.ts
Running the built esm version (git clone && yarn test:deno) works instead: https://github.com/virtualstate/app-history/runs/4606670052?check_suite_focus=true#step:8:11
This means that I cannot use the direct typescript version of this module.
I'm not sure how to debug this here.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
I checked latest deno and it is still present
deno --version
deno 1.21.0 (release, aarch64-apple-darwin)
v8 10.0.139.17
typescript 4.6.2
Check https://deno.land/x/[email protected]/src/tests/index.ts
error: TS2502 [ERROR]: 'thisArg' is referenced directly or indirectly in its own type annotation.
bind<T>(this: T, thisArg: ThisParameterType<T>): OmitThisParameter<T>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at asset:///lib.es5.d.ts:352:22
As a side note I also get this error now with latest typescript (4.6.4, not with any version before, and also not with nightly - therefore I guess they fixed an upstream bug already):
node_modules/typescript/lib/lib.es5.d.ts:352:22 - error TS2502: 'thisArg' is referenced directly or indirectly in its own type annotation.
352 bind<T>(this: T, thisArg: ThisParameterType<T>): OmitThisParameter<T>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in node_modules/typescript/lib/lib.es5.d.ts:352
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.