0
請幫助我,我不明白如何在TS中使用es6模塊。 例如:我不明白如何使用es6模塊打字稿2
我試着將ext.class導入到class1.ts。
class1.ts
import ExtClass from "./ext.class";
class Class1 {
constructor(){
console.log(new ExtClass().title)
console.log("Work")
}
}
new Class1();
其出口類
ext.class.ts
class ExtClass {
public title: string = "ExtClass work";
}
export default ExtClass
package.json
{
"name": "ts_def",
"version": "0.0.0",
"license": "MIT",
"private": true,
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"lite": "lite-server"
},
"dependencies": {
"core-js": "^2.4.1",
"ts-helpers": "^1.1.1"
},
"devDependencies": {
"@types/jasmine": "^2.2.30",
"@types/node": "^6.0.42",
"codelyzer": "~0.0.26",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.2",
"concurrently": "^3.0.0",
"lite-server": "^2.2.2"
}
}
tsconfig.json
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es6",
"typeRoots": [
"../node_modules/@types"
]
}
}
在結果我收到的CLI和瀏覽器意外令牌進口。請告訴我,什麼是錯的?