Using TypeScript with SystemJS, how can I import a JSON file using plugin-json
?
If I write System.import('myjson.json!json').then(...)
then it imports it asynchronously and not as a part of System.register([...])
.
So, how can I import a JSON file as a part of System.register([...])
and convincing TypeScript to agree to this? (without then
Promise syntax).
Note:
I'm using the tsc
flag -m system
A possible solution is to use the -m umd
option for tsc
instead of -m system
, then I can do the following:
/// <reference path="typings/requirejs/require.d.ts" />
var myJson = require('myJson.json!json')
However, still waiting for an answer regarding usage of -m system
.
In order to do : import json = require('myJson.json!json')
You need to have some .d.ts
file with the following:
declare module 'myJson.json!json'{
var json:any;
export = json;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With