Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Unexpected token" parse error #13179

Open
benmccann opened this issue Sep 9, 2024 · 5 comments
Open

"Unexpected token" parse error #13179

benmccann opened this issue Sep 9, 2024 · 5 comments

Comments

@benmccann
Copy link
Member

Describe the bug

Svelte 5 fails to parse code that Svelte 4 handled:

  $: jobDetails = <Partial<Record<JobName, JobDetails>>>{
    [JobName.ThumbnailGeneration]: {
      icon: mdiFileJpgBox,
      title: $getJobName(JobName.ThumbnailGeneration),
      subtitle: $t('admin.thumbnail_generation_job_description'),
    },
    [JobName.MetadataExtraction]: {
      icon: mdiTable,
      title: $getJobName(JobName.MetadataExtraction),
      subtitle: $t('admin.metadata_extraction_job_description'),
    },
    [JobName.Library]: {
      icon: mdiLibraryShelves,
      title: $getJobName(JobName.Library),
      subtitle: $t('admin.library_tasks_description'),
      allText: $t('all').toUpperCase(),
      missingText: $t('refresh').toUpperCase(),
    },
    [JobName.Sidecar]: {
      title: $getJobName(JobName.Sidecar),
      icon: mdiFileXmlBox,
      subtitle: $t('admin.sidecar_job_description'),
      allText: $t('sync').toUpperCase(),
      missingText: $t('discover').toUpperCase(),
      disabled: !$featureFlags.sidecar,
    },
    [JobName.SmartSearch]: {
      icon: mdiImageSearch,
      title: $getJobName(JobName.SmartSearch),
      subtitle: $t('admin.smart_search_job_description'),
      disabled: !$featureFlags.smartSearch,
    },
    [JobName.DuplicateDetection]: {
      icon: mdiContentDuplicate,
      title: $getJobName(JobName.DuplicateDetection),
      subtitle: $t('admin.duplicate_detection_job_description'),
      disabled: !$featureFlags.duplicateDetection,
    },
    [JobName.FaceDetection]: {
      icon: mdiFaceRecognition,
      title: $getJobName(JobName.FaceDetection),
      subtitle: $t('admin.face_detection_description'),
      handleCommand: handleConfirmCommand,
      disabled: !$featureFlags.facialRecognition,
    },
    [JobName.FacialRecognition]: {
      icon: mdiTagFaces,
      title: $getJobName(JobName.FacialRecognition),
      subtitle: $t('admin.facial_recognition_job_description'),
      handleCommand: handleConfirmCommand,
      disabled: !$featureFlags.facialRecognition,
    },
    [JobName.VideoConversion]: {
      icon: mdiVideo,
      title: $getJobName(JobName.VideoConversion),
      subtitle: $t('admin.video_conversion_job_description'),
    },
    [JobName.StorageTemplateMigration]: {
      icon: mdiFolderMove,
      title: $getJobName(JobName.StorageTemplateMigration),
      allowForceCommand: false,
      description: StorageMigrationDescription,
    },
    [JobName.Migration]: {
      icon: mdiFolderMove,
      title: $getJobName(JobName.Migration),
      subtitle: $t('admin.migration_job_description'),
      allowForceCommand: false,
    },
  };

Reproduction

https://github.com/immich-app/immich/blob/8cf33690b8ddd8e36bdf5d968c3d5700bfcc2949/web/src/lib/components/admin-page/jobs/jobs-panel.svelte#L60

Logs

No response

System Info

5.0.0-next.244

Severity

annoyance

@Conduitry
Copy link
Member

Conduitry commented Sep 9, 2024

@7nik
Copy link

7nik commented Sep 9, 2024

Probably TyrealHu/acorn-typescript#58

@dummdidumm
Copy link
Member

dummdidumm commented Sep 10, 2024

Yeah probably - I think Acorn-Typescript doesn't parse type casts using <..> properly

@nstuyvesant
Copy link

Yeah probably - I think Acorn-Typescript doesn't parse type casts using <..> properly

Prior to Svelte 5 this worked...

function displayClass(classId: number): void {
  displayedClass = <ClassRecord>findParentRecord($classes, classId)
}

Now it has to be...

function displayClass(classId: number): void {
  displayedClass = findParentRecord($classes, classId) as ClassRecord
}

TSX does not permit the first type of casting (but I'm using regular TypeScript). Is it possible Acorn-TypeScript is treating TypeScript as TSX?

@Conduitry
Copy link
Member

Yes, that is what is described in the linked issue above: TyrealHu/acorn-typescript#58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants