ionic-team / ionic-team/ionic-angular-standalone-codemods
bug: SyntaxError: Unexpected token
- Ngôn ngữ chính
- TypeScript
- Star
- 20
- Fork
- 9
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
### Prerequisites
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-angular-standalone-codemods) that already report this problem, without success.
### Codemod version
v0.4.0
### Current Behavior
During the Dry-Run using ionic-angular-standalone-codemods command, I get an error:
` An error occurred during the migration.
│
■ SyntaxError: Unexpected token ']', ..." ],
│ "... is not valid JSON
│ at JSON.parse ()
│ at migrateAngularJsonAssets (C:\Users\donny\AppData\Local\npm-cache\_npx\ff04957b6f1fa49f\node_modules\@ionic\angular-standalone-codemods\dist\index.js:904:28)
│ at runStandaloneMigration (C:\Users\donny\AppData\Local\npm-cache\_npx\ff04957b6f1fa49f\node_modules\@ionic\angular-standalone-codemods\dist\index.js:1033:9)
│ at async main (C:\Users\donny\AppData\Local\npm-cache\_npx\ff04957b6f1fa49f\node_modules\@ionic\angular-standalone-codemods\dist\index.js:1139:5)
`
It appears to be during a specific component, my `video.page.ts` one. Here is that:
`
import {Component, inject} from '@angular/core';
import {DomSanitizer, SafeResourceUrl} from "@angular/platform-browser";
import { MenuController, NavController, Platform, ToastController, IonicModule } from "@ionic/angular";
import {Clipboard} from '@angular/cdk/clipboard';
import {WatchModel} from "../../models/sub-models/watch.model";
import { MatFormField, MatLabel, MatHint } from '@angular/material/form-field';
import { MatInput } from '@angular/material/input';
import { FormsModule } from '@angular/forms';
import { FooterComponent } from '../footer/footer.component';
import { DatePipe } from '@angular/common';
@Component({
selector: 'app-video',
templateUrl: './video.page.html',
styleUrls: ['./video.page.scss'],
standalone: true,
imports: [
IonicModule,
MatFormField,
MatLabel,
MatInput,
FormsModule,
MatHint,
FooterComponent,
DatePipe,
],
})
export class VideoPage {
private clipboard = inject(Clipboard);
private toastController = inject(ToastController);
private platform = inject(Platform);
private sanitizer = inject(DomSanitizer);
private navCtrl = inject(NavController);
private menuCtrl = inject(MenuController);
textArea: string = "";
defaultUrl: string = "https://www.youtube.com/embed/";
opened: boolean = false;
anyCard: WatchModel;
youtubeUrl: SafeResourceUrl;
constructor() {
this.anyCard = JSON.parse(localStorage.getItem('card'));
this.youtubeUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.defaultUrl + this.anyCard.videoId);
}
openTextArea() {
this.opened = !this.opened;
}
copyText() {
this.clipboard.copy(this.textArea);
this.presentToast();
}
copyUrlToClipboard(id: string) {
const shareUrl: string = 'https://www.youtube.com/watch?v=' + id;
this.clipboard.copy(shareUrl);
this.presentToastForShare();
}
async presentToast() {
const toast = await this.toastController.create({
cssClass: 'custom-toast-class',
message: 'Your Notes have been copied to your clipboard!',
duration: 2000,
position: 'bottom'
});
await toast.present();
}
async presentToastForShare() {
const toast = await this.toastController.create({
cssClass: 'custom-toast-class',
message: 'The Youtube URL has been copied to your clipboard!',
duration: 2000,
position: 'bottom'
});
await toast.present();
}
back() {
this.navCtrl.back();
this.menuCtrl.enable(true, 'menu-one');
}
}
`
### Expected Behavior
I wasn't sure what to expect as I have recently just migrated to Angular standalone components and I have an Ionic/Angular project so I decided to do Angular first, then Ionic.
### Steps to Reproduce
1. Run the `npx @ionic/angular-standalone-codemods` command
2. Select Dry-run
3. select application directory.
### Code Reproduction URL
_No response_
### Additional Information
I clearly see it says "... is not valid JSON at JSON PARSE." So I thought huh, maybe it's my localStorage cause that's the only JSON.parse I have in my application. I removed it and ran it again but still the same error persisted. It ran I think fine for all the other classes as they printed out and didn't seem to throw an error. It's just when I got to Video page file.
Forgive me for the code not formatting, I keep trying to insert into code block and it's not doing it.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.