Last active
October 29, 2016 07:07
-
-
Save tpluscode/d962f5bb894392dd6f7887f07a2d5ca7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path='typings/index.d.ts' /> | |
import {promises as jsonld} from 'jsonld'; | |
import {jsonLdObject, JsonLdResource} from './SampleObjects'; | |
// this works fine, JS object literal passed directly to jsond.js | |
jsonld.expand({ | |
'@context': 'http://schema.org/', | |
'@id': 'http://example.com/tpluscode', | |
'@type': 'Person', | |
givenName: 'Tomasz' | |
}).then(log); | |
// these two calls throw a compilation error | |
jsonld.expand(jsonLdObject).then(log); | |
jsonld.expand(new JsonLdResource()).then(log); | |
function log(expanded) { | |
console.log(JSON.stringify(expanded, null, 2)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"jsonld": "^0.4.11" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export var jsonLdObject = { | |
'@context': 'http://schema.org/', | |
'@id': 'http://example.com/tpluscode', | |
'@type': 'Person', | |
givenName: 'Tomasz' | |
}; | |
export class JsonLdResource { | |
get '@context'() { | |
return 'http://schema.org'; | |
} | |
get '@id'() { | |
return 'http://example.com/tpluscode'; | |
} | |
get '@type'() { | |
return 'Person'; | |
} | |
get givenName() { | |
return 'Tomasz'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es5", | |
"module": "commonjs", | |
"moduleResolution": "node", | |
"sourceMap": true, | |
"emitDecoratorMetadata": true, | |
"experimentalDecorators": true, | |
"removeComments": false, | |
"noImplicitAny": false, | |
"suppressImplicitAnyIndexErrors": false | |
}, | |
"include": [ | |
"index.ts" | |
], | |
"exclude": [ | |
"typings" | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"jsonld": "registry:npm/jsonld#0.4.0+20161023213320" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment