TypeScript: TypeError: Cannot read property 'valueDeclaration' of undefined
TypeScript Version: 3.8.0-dev.20191101
Running into this exception when trying to create declarations from .js
files. Cannot use the Playground to illustrate this; it doesn’t support .d.ts
generation
Using tsconfig.json
:
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"declaration": true,
"emitDeclarationOnly": true
},
"include": ["foo.js"]
}
Run tsc
, which should create foo.d.ts
. Run it again to get the error.
Expected behavior:
a different error about refusing to overwrite .d.ts
files
Actual behavior:
$ tsc
/Users/boneskull/projects/boneskull/sync-monorepo-packages/node_modules/typescript/lib/tsc.js:78600
throw e;
^
TypeError: Cannot read property 'valueDeclaration' of undefined
at getExpandoSymbol (/Users/boneskull/projects/boneskull/sync-monorepo-packages/node_modules/typescript/lib/tsc.js:28794:31)
at getTypeReferenceType (/Users/boneskull/projects/boneskull/sync-monorepo-packages/node_modules/typescript/lib/tsc.js:35293:22)
at getTypeFromJSDocValueReference (/Users/boneskull/projects/boneskull/sync-monorepo-packages/node_modules/typescript/lib/tsc.js:35332:32)
at getTypeReferenceType (/Users/boneskull/projects/boneskull/sync-monorepo-packages/node_modules/typescript/lib/tsc.js:35307:33)
at resolveImportSymbolType (/Users/boneskull/projects/boneskull/sync-monorepo-packages/node_modules/typescript/lib/tsc.js:36697:24)
at getTypeFromImportTypeNode (/Users/boneskull/projects/boneskull/sync-monorepo-packages/node_modules/typescript/lib/tsc.js:36672:42)
at getTypeFromTypeNode (/Users/boneskull/projects/boneskull/sync-monorepo-packages/node_modules/typescript/lib/tsc.js:37005:28)
at getTypeFromTypeNode (/Users/boneskull/projects/boneskull/sync-monorepo-packages/node_modules/typescript/lib/tsc.js:36982:28)
at getDeclaredTypeOfTypeAlias (/Users/boneskull/projects/boneskull/sync-monorepo-packages/node_modules/typescript/lib/tsc.js:33085:39)
at tryGetDeclaredTypeOfSymbol (/Users/boneskull/projects/boneskull/sync-monorepo-packages/node_modules/typescript/lib/tsc.js:33216:24)
This may or may not have anything to do with the fact I’m only generating declarations from .js
files.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 13
- Comments: 26 (9 by maintainers)
Commits related to this issue
- do not use typescript 3.7.2 as it has a bug with javascript files --> https://github.com/microsoft/TypeScript/issues/34869 — committed to Financial-Times/origami-build-service-v3 by deleted user 5 years ago
- do not use typescript 3.7.2 as it has a bug with javascript files --> https://github.com/microsoft/TypeScript/issues/34869 — committed to Financial-Times/origami-build-service-v3 by deleted user 5 years ago
- do not use typescript 3.7.2 as it has a bug with javascript files --> https://github.com/microsoft/TypeScript/issues/34869 — committed to Financial-Times/origami-build-service-v3 by deleted user 5 years ago
- do not use typescript 3.7.2 as it has a bug with javascript files --> https://github.com/microsoft/TypeScript/issues/34869 — committed to Financial-Times/origami-build-service-v3 by deleted user 5 years ago
- do not use typescript 3.7.2 as it has a bug with javascript files --> https://github.com/microsoft/TypeScript/issues/34869 — committed to Financial-Times/origami-build-service-v3 by deleted user 5 years ago
- do not use typescript 3.7.2 as it has a bug with javascript files --> https://github.com/microsoft/TypeScript/issues/34869 — committed to Financial-Times/origami-build-service-v3 by deleted user 5 years ago
- DO NOT MERGE: example repo for problem in microsoft/typescript#34869 — committed to IBM/report-toolkit by boneskull 5 years ago
- Fix `getTypeFromJSDocValueReference` When using `{import('./b').FOO}` which is defined as a string literal, `valueType` doesn't have a `symbol`. This was exposed in 8223c0752. Fixes #34869. — committed to elibarzilay/TypeScript by elibarzilay 5 years ago
- Fix `getTypeFromJSDocValueReference` When using `{import('./b').FOO}` which is defined as a string literal, `valueType` doesn't have a `symbol`. Leave it for the fallback value for now. This was ex... — committed to elibarzilay/TypeScript by elibarzilay 5 years ago
- Fix `getTypeFromJSDocValueReference` When using `{import('./b').FOO}` which is defined as a string literal, `valueType` doesn't have a `symbol`. Leave it for the fallback value for now. This was ex... — committed to microsoft/TypeScript by elibarzilay 5 years ago
- Fix `getTypeFromJSDocValueReference` When using `{import('./b').FOO}` which is defined as a string literal, `valueType` doesn't have a `symbol`. Leave it for the fallback value for now. This was ex... — committed to microsoft/TypeScript by elibarzilay 5 years ago
Has this been fixed? Im still getting the error testing against
v3.8.0-dev.20191205
Here is my stack trace (the first one is react-styleguidist)
I just rolled back to the version 3.6.4: No errors with the same code.
Hey @RyanCavanaugh, you have critical production bug here in your compiler!
Any update on this? I’m getting the error with the same stracktrace as @jasonwilliams, but unfortunately cannot narrow it down and make a repro as my project is pretty large and stack doesn’t help at all.
I’m seeing the same stacktrace as @jasonwilliams
Version: typescript 3.8.0-dev.20191207
I have created a minimal example to reproduce the issue in OpenLayers.
See https://gist.github.com/ahocevar/b3e58e7eac7750faa235ef66bdb559ab.
The problem appears to be related to the
getTypeOfSymbol()
call in thegetTypeFromJSDocValueReference()
function. In the above example, the return type ofPointFoo
’sgetType()
method is not found, andgetTypeOfSymbol()
returns anerrorType
.I’ve also seen this issue when upgrading to TypeScript 3.7.2 (3.6.4 works fine)
I’ve narrowed it down so that I can only see the error (
Cannot read property 'valueDeclaration' of undefined
) when type annotations like the following are included:This is the syntax I currently use to annotate that a parameter is an instance of a class which is definied in a separate
.js
file. I also talk about this here: https://github.com/microsoft/TypeScript/issues/29485#issuecomment-518316889I’ve created a small gist which should reproduce the problem: https://gist.github.com/lukehesluke/8ef8e7061c6533e208e055aedb4e31b1
Keen to see how this develops and happy to help if that’s useful
@ahocevar Thanks for that! – I went through minimizing the “far cry” example above, which took almost the same time as getting through a far cry game, and got something manageable. The problem is when using an
import
in a jsdoc as you have inindex.js
.I checked that it’s fixed now, but it’ll still be interesting to look at since it’s slightly different.
Same is happening for us, the stacktrace only includes typescript files so i don’t know what’s causing it 😦
I tried on 3.8.0-dev.20191105 and it was still the same
I have the same issue. 😦
I have no ts files in my repository, and only a couple that use jsdocs to import jsdoc typedefs and none of them use imports like @lukehesluke
Any advice for tracking down the offending file?
I was having this same issue with the new Typescript 3.7.2. The problem was the import below that’s importing a
const
instead of a type.Component.jsx
app/utils/validations.js