foundry-vtt-types icon indicating copy to clipboard operation
foundry-vtt-types copied to clipboard

Typescript 4.7 - document.mjs.d.ts - Return type annotation circularly references itself

Open gsouf opened this issue 3 years ago • 4 comments

Foundry VTT Version

v9

Description

Hi,

Running typescript on fvtt types returns the following error:

node_modules/@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/abstract/document.mjs.d.ts:150:6 - error TS2577: Return type annotation circularly references itself.

150   ): TemporaryDocument<this> | Promise<TemporaryDocument<this> | undefined>;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in node_modules/@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/abstract/document.mjs.d.ts:150

That's happening with version 4.7.4 of typescript - but it works well on version 4.6.2

Reproduction Steps

Use typescript 4.7.4

Expected Behavior

should work

Additional Context

Thanks

gsouf avatar Jul 29 '22 16:07 gsouf

It doesn't seem to be an error in the types themselves, as there is no compile error when running a type check across the types themselves.

Due to the way the types are used, by injecting your own configuration into them, it's possible to introduce errors from the user side that show up as errors in the library. In order to figure out what the error actually is and to check if it's an error with your usage of the types, or an error in the types after all, we need to take a closer look at the project that the error happens in. Could you give a link to a branch of your project that exhibits the problem? I would also guess that the compile error contains a bit more information about the circular reference issue, or more error messages. Could you please provide the full error message(s)?

ghost91- avatar Jul 29 '22 18:07 ghost91-

@ghost91-

You can clone this project https://bitbucket.org/rpgframework-cloud/shadowrun6-eden/src/master/ and in package.json replace typescript version to be 4.7.4 and run npm install then npm run build. Hope that will help

gsouf avatar Aug 01 '22 13:08 gsouf

@gsouf Sorry, but since we are so busy with trying to get the types to work properly for v10, I don't have the capacity to properly look into this in more detail right now.

As a workaround, can you make it work by specifying "skipLibCheck": true in your tsconfig.json file?

ghost91- avatar Aug 19 '22 22:08 ghost91-

@ghost91- thanks for your message. I keep using older version of typescript for now not a big deal

gsouf avatar Aug 22 '22 08:08 gsouf

We appeared to have slayed the circularity dragon. I am closing this ticket!

JPMeehan avatar Jun 10 '24 05:06 JPMeehan