diff --git a/.babelrc b/.babelrc index dfb789cd44ba0e6b8f22e3479dd33bfe8b1fd83e..0af68049be3214a485fcf9f67cc9dff636f70c47 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,4 @@ { - "presets": ["@babel/env"] + "presets": ["@babel/env"], + "plugins": ["@babel/plugin-proposal-class-properties"] } \ No newline at end of file diff --git a/js/main.js b/js/main.js index 807180b95240c3dece9b3941e2ddee11a4baeda7..daca8328c77359e27c2be2e4d97afc139460cee8 100644 --- a/js/main.js +++ b/js/main.js @@ -20,4 +20,15 @@ const data = [ prix_grande: 8, image: 'https://images.unsplash.com/photo-1458642849426-cfb724f15ef7?fit=crop&w=500&h=300' } -]; \ No newline at end of file +]; + +class Animal { + constructor( name ){ + this.name = name; + } + fly() { // déclaration de méthode + console.log(`${this.name} is flying !`); + } +} +const threeEyedRaven = new Animal( 'Bran' ); +threeEyedRaven.fly(); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1b1cf6e0c0cfc37d17af63f96a8f76a74a9f9406..a9499ca5ed81e6d3b8e705c0fb2431f73f6045b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -136,6 +136,20 @@ "semver": "^5.5.0" } }, + "@babel/helper-create-class-features-plugin": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.8.3.tgz", + "integrity": "sha512-qmp4pD7zeTxsv0JNecSBsEmG1ei2MqwJq4YQcK3ZWm/0t07QstWfvuV/vm3Qt5xNMFETn2SZqpMx2MQzbtq+KA==", + "dev": true, + "requires": { + "@babel/helper-function-name": "^7.8.3", + "@babel/helper-member-expression-to-functions": "^7.8.3", + "@babel/helper-optimise-call-expression": "^7.8.3", + "@babel/helper-plugin-utils": "^7.8.3", + "@babel/helper-replace-supers": "^7.8.3", + "@babel/helper-split-export-declaration": "^7.8.3" + } + }, "@babel/helper-create-regexp-features-plugin": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.8.3.tgz", @@ -347,6 +361,16 @@ "@babel/plugin-syntax-async-generators": "^7.8.0" } }, + "@babel/plugin-proposal-class-properties": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.8.3.tgz", + "integrity": "sha512-EqFhbo7IosdgPgZggHaNObkmO1kNUe3slaKu54d5OWvy+p9QIKOzK1GAEpAIsZtWVtPXUHSMcT4smvDrCfY4AA==", + "dev": true, + "requires": { + "@babel/helper-create-class-features-plugin": "^7.8.3", + "@babel/helper-plugin-utils": "^7.8.3" + } + }, "@babel/plugin-proposal-dynamic-import": { "version": "7.8.3", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.8.3.tgz", diff --git a/package.json b/package.json index e229001c9a9483e2f5067bc7257ff2d7b72d1f0e..334a953aa896f3f69e3430f65a60aa67b09ec933 100644 --- a/package.json +++ b/package.json @@ -4,15 +4,16 @@ "description": "", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "build": "babel js -d build", - "watch": "babel js -d build --verbose --watch --source-maps" + "test": "echo \"Error: no test specified\" && exit 1", + "build": "babel js -d build", + "watch": "babel js -d build --verbose --watch --source-maps" }, "author": "thomas.fritsch@univ-lille.fr", "license": "ISC", "devDependencies": { "@babel/cli": "^7.8.4", "@babel/core": "^7.8.4", + "@babel/plugin-proposal-class-properties": "^7.8.3", "@babel/preset-env": "^7.8.4" } }