Subscribe on changes!

Generating declarations for readonly/shallowReadonly ref causes TS4058 error

avatar
Sep 29th 2021

Version

3.2.19

Reproduction link

github.com

Steps to reproduce

Run npm run build command

What is expected?

The source should be successfully compiled into .js with .d.ts declarations

What is actually happening?

The TS4058 error occurs because of RefSymbol that is used by readonly(ref) internally


The issue occurs only when "declarations": true is set in tsconfig.json as TypeScript can't resolve RefSymbol type when generating related .d.ts file

avatar
Sep 29th 2021

Maybe RefSymbol should be renamed to _RefSymbol, marked as @internal in its comment, and exported. There are probably a few other missing exports reported by api-extractor

avatar
Sep 29th 2021

I found that the reason is found in our Deepreadonly type.

It currently doesn't account for Refs, and instead treats refs like plain objects, which exposes that RefSymbol property as a result of the recursive nature of this type.

I'll send a patch later