【发布时间】:2016-11-21 14:57:07
【问题描述】:
我试图解决这个问题已经超过 6-8 个小时。 我认为问题之一是我的英语。 =)
我使用原子编辑器、电子、打字稿、反应
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"isolatedModules": false,
"jsx": "react",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": false,
"noImplicitAny": false,
"noImplicitUseStrict": false,
"removeComments": true,
"noLib": false,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true
},
"exclude": [
"node_modules",
"typings/browser",
"typings/browser.d.ts"
],
"compileOnSave": true,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
app.ts:
import {hello} from "./func";
hello("TypeScript");
func.ts
export function hello(name: string){
console.log(`Hello, ${name}`);
}
启动电子并得到错误:
Uncaught SyntaxError: Unexpected token import
然后,创建文件 react-test.ts:
import * as React from "react";
在原子编辑器中出错:
Cannot find module 'react'
问题: 我不想要更多的理论。有一个具体的例子。请帮我解决它。顺便说一句,我对 babel 没有任何问题 =)
更新 #1:
电子运行命令:
npm start
github上的项目
【问题讨论】:
-
这可能是许多不同的问题,我们需要更多信息来了解问题所在。具体来说,你是如何运行电子的?你是如何运行 tsc 的?这和电子有什么关系?您的 index.html 文件是什么样的?你的
package.json文件是什么样的? -
我刚刚找到了一个示例导入文件并尝试实现它。电子运行命令
npm start,github link。它只是电子快速入门示例 + typescript + react + redux
标签: javascript node.js reactjs typescript electron