Last active
October 13, 2017 12:03
-
-
Save kvikende/0fb762e38fc0d1bfe1aebf786fd2ca59 to your computer and use it in GitHub Desktop.
Typescript renderer import fails
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 class Dataset { | |
name:string | |
data: Data[] | |
constructor(name: string) { | |
this.data = new Data[]; | |
} | |
} | |
export class Data { | |
time: Date | |
value: number | |
constructor(time: Date, value: number) { | |
this.time = time; | |
this.value = value; | |
} | |
} |
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
const e = require("electron"); | |
//import {Dataset, Data} from "./dataset"; // Error, Uncaught ReferenceError: exports is not defined | |
const ds = require("./dataset"); // works but cannot access classes | |
e.ipcRenderer.on("send-data", (data) => { | |
let dataset = <ds.Dataset> data; // Error, cannot find namespace ds | |
for (let d of dataset.data) { | |
console.log("time: " + d.time + " value: " + d.value); | |
} | |
}); |
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
import dataset = require("./dataset"); | |
import {ipcMain} from "electron"; | |
function generateDataset(): Dataset { | |
let ds = new Dataset("testdata"); | |
for (let i=0; i<100; i++) { | |
let d = new Data(new Date(), i); | |
ds.data.push(d); | |
} | |
ipcMain.sender.send("send-data", ds); | |
} |
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": { | |
"outDir": "./built", | |
"allowJs": true, | |
"target": "es5", | |
"moduleResolution": "node", | |
"module": "commonjs", | |
"sourceMap": true | |
}, | |
"include": [ | |
"./src/**/*" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment