TypeScript: TypeError: Cannot read property 'flags' of undefined when running TSC
Hi! π
Firstly, thanks for your work on this project! π
Today I used patch-package to patch typescript@4.6.2
for the project Iβm working on.
We encountered this when upgrading from typescript 4.1.3 to a higher version. Here is the diff that solved my problem:
diff --git a/node_modules/typescript/lib/tsc.js b/node_modules/typescript/lib/tsc.js
index 7704b1a..65cf863 100644
--- a/node_modules/typescript/lib/tsc.js
+++ b/node_modules/typescript/lib/tsc.js
@@ -71362,8 +71362,9 @@ var ts;
if (!symbol) {
return false;
}
+ console.log(symbol)
var target = getExportSymbolOfValueSymbolIfExported(resolveAlias(symbol));
- if (target === unknownSymbol) {
+ if (!target || target === unknownSymbol) {
return true;
}
return !!(target.flags & 111551) &&
This issue body was partially generated by patch-package.
Without this patch, I get this:
> tsc -p tsconfig.build.json
/home/capaj/work-repos/secret-project/backend/node_modules/typescript/lib/tsc.js:95304
throw e;
^
TypeError: Cannot read property 'flags' of undefined
at isAliasResolvedToValue (/home/capaj/work-repos/secret-project/backend/node_modules/typescript/lib/tsc.js:71369:30)
at isValueAliasDeclaration (/home/capaj/work-repos/secret-project/backend/node_modules/typescript/lib/tsc.js:71341:40)
at Object.isValueAliasDeclaration (/home/capaj/work-repos/secret-project/backend/node_modules/typescript/lib/tsc.js:71675:35)
at visitExportSpecifier (/home/capaj/work-repos/secret-project/backend/node_modules/typescript/lib/tsc.js:76896:49)
at Object.visitNodes (/home/capaj/work-repos/secret-project/backend/node_modules/typescript/lib/tsc.js:73579:48)
at visitNamedExports (/home/capaj/work-repos/secret-project/backend/node_modules/typescript/lib/tsc.js:76886:31)
at visitNamedExportBindings (/home/capaj/work-repos/secret-project/backend/node_modules/typescript/lib/tsc.js:76893:79)
at /home/capaj/work-repos/secret-project/backend/node_modules/typescript/lib/tsc.js:76880:93
at Object.visitNode (/home/capaj/work-repos/secret-project/backend/node_modules/typescript/lib/tsc.js:73540:23)
at visitExportDeclaration (/home/capaj/work-repos/secret-project/backend/node_modules/typescript/lib/tsc.js:76880:35)
I have logged the symbol just before the crash and that prints out like this:
<ref *1> Symbol {
flags: 2097152,
escapedName: 'staticServerApi',
declarations: [
Node {
pos: 8,
end: 35,
kind: 274,
id: 0,
flags: 32768,
modifierFlagsCache: 536870912,
transformFlags: 0,
parent: [Node],
original: undefined,
isTypeOnly: false,
propertyName: [Identifier],
name: [Identifier],
symbol: [Circular *1]
}
],
valueDeclaration: undefined,
id: 17655,
mergeId: undefined,
parent: <ref *2> Symbol {
flags: 512,
escapedName: '"/home/capaj/work-repos/momence/ribbon-backend/routes/index"',
declarations: [ [Node] ],
valueDeclaration: Node {
pos: 0,
end: 2495,
kind: 303,
id: 61756,
flags: 0,
modifierFlagsCache: 0,
transformFlags: 0,
parent: undefined,
original: undefined,
statements: [Array],
endOfFileToken: [Token],
fileName: '/home/capaj/work-repos/momence/ribbon-backend/routes/index.ts',
text: "export { default as staticServerApi } from './static-server-api'\n" +
"export { default as hostLandingPage } from './host-landing-page'\n" +
"export { default as hostDashboardAnnouncements } from './host-dashboard/announcements'\n" +
"export { default as hostDashboardSms } from './host-dashboard/sms'\n" +
"export { default as hostDashboardSmsMessaging } from './host-dashboard/sms/messaging'\n" +
"export { default as hostDashboardBilling } from './host-dashboard/billing'\n" +
"export { default as hostDashboardOndemandVideoOptimizations } from './host-dashboard/ondemand-video-optimizations'\n" +
'\n' +
"export { adminRoutes } from './admin'\n" +
"export { apiRoutes } from './api'\n" +
"export { hostDashboardCrm } from './host-dashboard/crm'\n" +
"export { publicApiRoutes } from './public-api'\n" +
"export { hostDasboardRoutes } from './host-dashboard/dashboard'\n" +
"export { hostDashboardOndemandLibraryRoutes } from './host-dashboard/ondemand-library'\n" +
"export { authRoutes } from './auth'\n" +
"export { onDemandRoutes } from './ondemand-plugin'\n" +
"export { awsS3OperationsRoutes } from './aws-s3-operations'\n" +
"export { feedRoutes } from './feed'\n" +
"export { pluginRoutes } from './plugin'\n" +
"export { studioRoutes } from './host-dashboard/studio'\n" +
"export { discountCodesRoutes } from './host-dashboard/discount-codes'\n" +
"export { adminPanelRoutes } from './admin/admin-panel'\n" +
"export { hostDashboardRoutes } from './host-dashboard'\n" +
"export { memberPortalRoutes } from './member-portal'\n" +
"export { integrationsRoutes } from './integrations'\n" +
"export { pollsRoutes } from './poll'\n" +
"export { kioskRoutes } from './kiosk'\n" +
"export { hostDashboardAppointmentsRoutes } from './host-dashboard/appointments'\n" +
"export { webhooksRoutes } from './webhooks'\n" +
"export { pluginAppointmentsRoutes } from './plugin/appointments'\n" +
"export { mobileRoutes } from './mobile'\n" +
"export { docsRoutes } from './docs'\n" +
"export { landingPageRoutes } from './landing-page'\n" +
"export { memberPortalAppointmentsRoutes as memberDashboardAppointmentsRoutes } from './member-portal/appointments'\n" +
"export { hostDashboardTransactionalTemplatesRoutes } from './host-dashboard/transactionalMessages'\n" +
"export { hostDashboardMarketingMessagesRoutes } from './host-dashboard/marketingMessages'\n" +
"export { hostDashboardAutomationRoutes } from './host-dashboard/automations'\n" +
"export { hostDashboardIntegrationsRoutes } from './host-dashboard/integrations'\n" +
"export { hostDashboardPosRoutes } from './host-dashboard/pos'\n" +
"export { hostDashboardApplicationAddonsRoutes } from './host-dashboard/applicationAddons'\n" +
"export { signUpRoutes } from './sign-up'\n",
languageVersion: 7,
languageVariant: 0,
scriptKind: 3,
isDeclarationFile: false,
hasNoDefaultLib: false,
externalModuleIndicator: [Node],
bindDiagnostics: [],
bindSuggestionDiagnostics: undefined,
pragmas: Map(0) {},
checkJsDirective: undefined,
referencedFiles: [],
typeReferenceDirectives: [],
libReferenceDirectives: [],
amdDependencies: [],
commentDirectives: undefined,
nodeCount: 210,
identifierCount: 48,
identifiers: [Map],
parseDiagnostics: [],
version: '3a265a8b2eeff309dcecdda50184400dd25195aedd3eee988ab2ff8311622d5a',
path: '/home/capaj/work-repos/momence/ribbon-backend/routes/index.ts',
resolvedPath: '/home/capaj/work-repos/momence/ribbon-backend/routes/index.ts',
originalFileName: '/home/capaj/work-repos/momence/ribbon-backend/routes/index.ts',
impliedNodeFormat: undefined,
imports: [Array],
moduleAugmentations: [],
ambientModuleNames: [],
resolvedModules: [Object],
symbol: [Circular *2],
locals: Map(0) {},
endFlowNode: [Object],
symbolCount: 41,
classifiableNames: [Set]
},
id: 17654,
mergeId: undefined,
parent: undefined,
exports: Map(40) {
'staticServerApi' => [Circular *1],
'hostLandingPage' => [Symbol],
'hostDashboardAnnouncements' => [Symbol],
'hostDashboardSms' => [Symbol],
'hostDashboardSmsMessaging' => [Symbol],
'hostDashboardBilling' => [Symbol],
'hostDashboardOndemandVideoOptimizations' => [Symbol],
'adminRoutes' => [Symbol],
'apiRoutes' => [Symbol],
'hostDashboardCrm' => [Symbol],
'publicApiRoutes' => [Symbol],
'hostDasboardRoutes' => [Symbol],
'hostDashboardOndemandLibraryRoutes' => [Symbol],
'authRoutes' => [Symbol],
'onDemandRoutes' => [Symbol],
'awsS3OperationsRoutes' => [Symbol],
'feedRoutes' => [Symbol],
'pluginRoutes' => [Symbol],
'studioRoutes' => [Symbol],
'discountCodesRoutes' => [Symbol],
'adminPanelRoutes' => [Symbol],
'hostDashboardRoutes' => [Symbol],
'memberPortalRoutes' => [Symbol],
'integrationsRoutes' => [Symbol],
'pollsRoutes' => [Symbol],
'kioskRoutes' => [Symbol],
'hostDashboardAppointmentsRoutes' => [Symbol],
'webhooksRoutes' => [Symbol],
'pluginAppointmentsRoutes' => [Symbol],
'mobileRoutes' => [Symbol],
'docsRoutes' => [Symbol],
'landingPageRoutes' => [Symbol],
'memberDashboardAppointmentsRoutes' => [Symbol],
'hostDashboardTransactionalTemplatesRoutes' => [Symbol],
'hostDashboardMarketingMessagesRoutes' => [Symbol],
'hostDashboardAutomationRoutes' => [Symbol],
'hostDashboardIntegrationsRoutes' => [Symbol],
'hostDashboardPosRoutes' => [Symbol],
'hostDashboardApplicationAddonsRoutes' => [Symbol],
'signUpRoutes' => [Symbol]
}
}
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 8
- Comments: 15 (3 by maintainers)
Same issue π
Sorry this took so long @andrewbranch, hope this helps. If itβs useful, Iβm using yarn-3.1.1. I just tried again today, and still getting the error in the same package.
I had created a subrepo within my repo. My repo normally works, but with the subrepo it triggered the same error. The subrepo is the following: https://github.com/brettle/jsdoc-to-typescript-declaration
However, the error comes from the node modules of the top-level repo, not the inner one.
I deleted the subrepo and everything works correctly now.
I get the same error.