shakilsiraj / json-object-mapper

A TypeScript library to serialize and deserialize object graph from/to JSON in a fast and non-recursive way
MIT License
58 stars 18 forks source link

Unexpected token import #3

Closed jossErnesto closed 3 years ago

jossErnesto commented 7 years ago

I am replicating the example class from the wiki page: import {JsonProperty} from 'json-object-mapper'; export class SimpleRoster { private worksOnWeekend: Boolean = undefined; @JsonProperty({type: Date}) private systemDate: Date = undefined; public isAvailableToday(): Boolean { if (this.systemDate.getDay() % 6 === 0 && this.worksOnWeekend === false) { return false; } return true; }

} but i get this: .../node_modules\json-object-mapper\dist\ObjectMapper.es2015.js:1 (function (exports, require, module, filename, dirname) { import 'reflect-metadata';

is this the correct way?

shakilsiraj commented 7 years ago

Can you please provide a plukr or something similar example? Thanks.

findingorder commented 7 years ago

+1 with this problem. Is there some other dependency?

▶ node
> require('json-object-mapper')
/usr/local/lib/node_modules/json-object-mapper/dist/ObjectMapper.es2015.js:1
(function (exports, require, module, __filename, __dirname) { import 'reflect-metadata';
                                                              ^^^^^^
SyntaxError: Unexpected token import
shakilsiraj commented 7 years ago

@DeliciousPickle are u trying running directly on node?

if so, i don't think it's going to work as this is a typescript library. May I suggest looking into .. http://brianflove.com/2016/11/08/typescript-2-express-node/ ?