+ Start a Discussion
Vijay ummedaVijay ummeda 

LWC1503: Parsing error: Unexpected token

Hi Team,

can you please  help me on why we are getting the below error 

User-added image


19:12:51.998 ended SFDX: Deploy Source to Org
19:20:15.573 Starting SFDX: Deploy Source to Org
=== Deploy Errors
PROJECT PATH  ERRORS                                                
────────────  ──────────────────────────────────────────────────────
              LWC1503: Parsing error: Unexpected token (7:11) (7:11)
19:20:18.812 ended SFDX: Deploy Source to Org


Thanks,
Vijay.
Suraj Tripathi 47Suraj Tripathi 47
Hi Vijay,

Here recordId and objectApiName is a variable and you are using it as a string value, also use semicolon after the consol.log statement. 

If this answer is helpful for you then mark it as the best answer.
Vijay ummedaVijay ummeda
Hi Tripathi,

I tried but still i am getting the same error .

Js file :

import { LightningElement,api } from 'lwc';
export default class CurrentRecordAndObjectInfo extends LightningElement {
    @api recordId;
    @api objectApiName;
    console.log('recordId');
    console.log('objectApiName');
}

User-added image


Thanks,
Vijay.
Suraj Tripathi 47Suraj Tripathi 47
Hi Vijay,
Js file :

import { LightningElement,api } from 'lwc';
export default class CurrentRecordAndObjectInfo extends LightningElement {
    @api recordId;
    @api objectApiName;
    console.log('recordId'+recordID);
    console.log('objectApiName'+objectApiName);
}

Thanks 
Suraj Tripathi.

If this answer is helpful for you then mark it as the best answer.
Vijay ummedaVijay ummeda
Hi Suraj,
i have tried the above code but still seeing the error   parameter declartion expected .

User-added image


Thanks,
Vijay.
Suraj Tripathi 47Suraj Tripathi 47
Hi Vijay,
the javascript is a case sensitive so you have to right the same name as you define at @api
you can check that code below,s
Js file :
 
import { LightningElement,api } from 'lwc';
export default class CurrentRecordAndObjectInfo extends LightningElement {
    @api recordId;
    @api objectApiName;
    console.log('recordId'+recordId);
    console.log('objectApiName'+objectApiName);
}

Thanks 
Suraj Tripathi.
Vijay ummedaVijay ummeda
Hi Suraj,

I have changed the code but still  seeing the error 

.User-added image


{
    "resource": "/c:/Users/91773/OneDrive/Desktop/SFDCFACTS/CounterVaraibleLog/force-app/main/default/lwc/currentRecordAndObjectInfo/currentRecordAndObjectInfo.js",
    "owner": "typescript",
    "code": "1138",
    "severity": 8,
    "message": "Parameter declaration expected.",
    "source": "ts",
    "startLineNumber": 5,
    "startColumn": 27,
    "endLineNumber": 5,
    "endColumn": 28
}
Thanks,
Vijay