You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like this plugin is using deprecated SWC classes, which may be why it's triggering an error within SWC.
For instance, I'm getting this error:
[vite-plugin-deadfile-pre] Cannot read properties of undefined (reading 'map')
file: {redacted}/src/scripts/lib/intercom/IntercomProxy.ts
file: src/scripts/lib/intercom/IntercomProxy.ts
at ImportVisitor.visitTsFnParameters (node_modules/.pnpm/@[email protected]/node_modules/@swc/core/Visitor.js:590:23)
However, the error doesn't seem to be related to the file itself. If I go to the SWC playground, and compile with the same SWC version, no error occurs.
The file that is failing is:
importtype{IntercomSettings}from'./IntercomSettings'import{Intercom}from'./intercom-js.js'exportinterfaceIIntercomProxy{isIntercomLoaded: ()=>booleanisAdminImpersonatingUser: ()=>booleanisKillSwitchEnabled: ()=>booleanshouldCallIntercom: ()=>booleanupdate: (key: string,value: any)=>voidupdateObject: (obj: any)=>voidtrackEvent: (eventName: any,eventMetadata: any)=>voidaction: (actionName: string)=>void}// eslint-disable-next-line prefer-constexportletintercomProxy: IntercomProxyexportclassIntercomProxyimplementsIIntercomProxy{staticreadonlyUpdate: string='update'staticreadonlyTrackEvent: string='trackEvent'settings: Partial<IntercomSettings>constructor(settings?: Record<string,any>){this.settings=settings??{}// Assume that any instantiation of IntercomProxy with different// settings replaces the singleton's settings// eslint-disable-next-line @typescript-eslint/no-this-aliasif(intercomProxy){intercomProxy.settings=this.settings}}// don't do anything unless library loaded fineisIntercomLoaded(): boolean{returntypeofIntercom!=='undefined'}isAdminImpersonatingUser(settings?: Partial<IntercomSettings>): boolean{constset=settings??this.settingsreturnset?.isImpersonatedAdmin??false}// just while we get comfortable..isKillSwitchEnabled(): boolean{returnfalse}// any reason to not allow sending things to intercomshouldCallIntercom(): boolean{returnthis.isIntercomLoaded()&&!this.isAdminImpersonatingUser()&&!this.isKillSwitchEnabled()}// update the user attribute valueupdate(aName: string,aValue: any): void{if(this.shouldCallIntercom()){constupdateParams: any={}updateParams[aName]=aValueIntercom(IntercomProxy.Update,updateParams)}}updateObject(obj: any): void{if(this.shouldCallIntercom()){Intercom(IntercomProxy.Update,obj)}}// we use for page views and other actions/ feature accesstrackEvent(eventName: any,eventMetadata?: any): void{if(this.shouldCallIntercom()){Intercom(IntercomProxy.TrackEvent,eventName,eventMetadata)}}// Eg shutdown, bootaction(actionName: any): void{if(this.shouldCallIntercom()){Intercom(actionName)}}}intercomProxy=newIntercomProxy()exportinterfaceIIntercomDataFormatter{// TODO: define the object that this returns.formatListOfKeysToSendToIntercom: (keysList: any[])=>any// TODO: go find some dictionary interface in typescript and pass that.formatDictionaryToSendToIntercom: (keyValsList: any)=>any}exportclassIntercomDataFormatterimplementsIIntercomDataFormatter{formatListOfKeysToSendToIntercom(keysList: any): any{// send role keys to intercom: key is attribute, make "true" valueconstkeyObj: any={}if(typeofkeysList!=='undefined'&&keysList!=null&&keysList!==''){for(leti=0;i<keysList.length;i++){keyObj[keysList[i]]=true}}returnkeyObj}formatDictionaryToSendToIntercom: any=function(keyValsList: any){constkeyValObj: any={}if(typeofkeyValsList==='undefined'||keyValsList==null||keyValsList===''){returnkeyValObj}for(leti=0;i<keyValsList.length;i++){keyValObj[keyValsList[i].Key]=keyValsList[i].Value}returnkeyValObj}}
The text was updated successfully, but these errors were encountered:
I copied this file to an empty project and mocked './IntercomSettings.ts' and './intercom-js.js', the error can not be reproduced after vite build complete.
It looks like this plugin is using deprecated SWC classes, which may be why it's triggering an error within SWC.
For instance, I'm getting this error:
However, the error doesn't seem to be related to the file itself. If I go to the SWC playground, and compile with the same SWC version, no error occurs.
The file that is failing is:
The text was updated successfully, but these errors were encountered: