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

Module Parse failed #14

Open
garethkusky opened this issue Jun 27, 2018 · 0 comments
Open

Module Parse failed #14

garethkusky opened this issue Jun 27, 2018 · 0 comments

Comments

@garethkusky
Copy link

Hi. I've just started the course and had the node-sass compatibility issue, that was solved but i'm having an issue with the code for
Classes, Spread operator, Arrow functions, Immutability

When i save the changes i get the below error

Uncaught Error: Module parse failed: ...\Angular\angular-fundamentals-seed-master\main.ts Unexpected token (26:11)
You may need an appropriate loader to handle this file type.
|
| class ShoppingList2 {
| groceries: string[];
| constructor(){
| this.groceries = [];
at Object../main.ts (app.js:718) []
at webpack_require (app.js:660) []
at fn (app.js:84) []
at Object.7 (app.js:9976) []
at webpack_require (app.js:660) []
at ./main.ts (app.js:709) []
at :4000/build/app.js:712:10 []

Im guessing its some compatability issues but cannot work out which. Ive double checked the code and it looks good to me but here it is just in case

`
function ShoppingList() {
this.groceries = [];
}

ShoppingList.prototype.addItem = function (item) {
this.groceries = this.groceries.concat([item]);
}

ShoppingList.prototype.removeItem = function([item]){
this.groceries = this.groceries.filter(function(grocery){
return item !== grocery;
})
}
var mylist = new ShoppingList();

mylist.addItem('Banana');
mylist.addItem('Apple');

console.log(mylist.groceries);

mylist.removeItem('Banana');
console.log(mylist.groceries);

class ShoppingList2 {
groceries: string[];
constructor(){
this.groceries = [];
}
addItem(item){
this.groceries = [...this.groceries, item];
}
removeItem(item){
this.groceries = this.groceries.filter((grocery)=> item !== grocery)
}
}

const myNewList = new ShoppingList2();
myNewList.addItem('Pear');
myNewList.addItem('Pizza');

console.log(myNewList);
`

any ideas?

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

No branches or pull requests

1 participant