-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zchub
committed
Jun 3, 2020
1 parent
98f8fc0
commit e146ef9
Showing
6 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
function getCounter() { | ||
function counter(str) { | ||
} | ||
counter.title = '123'; | ||
counter.add = function (str) { }; | ||
return counter; | ||
} | ||
var counter = { | ||
title: '123', | ||
add: function (str1) { } | ||
}; | ||
var Sub = /** @class */ (function () { | ||
function Sub() { | ||
this.title = 'abc'; | ||
} | ||
Sub.prototype.add = function (str) { | ||
console.log(this.title + str); | ||
}; | ||
Sub.prototype.decerate = function (num) { | ||
return 1; | ||
}; | ||
return Sub; | ||
}()); | ||
exports["default"] = { | ||
run: function () { | ||
var sub = new Sub(); | ||
sub.add('-1234'); | ||
console.error(sub.decerate(1)); | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
interface Counter{ | ||
readonly start: number // 只读 | ||
title: string | ||
lable?: string // 可选属性 | ||
add(str: string): void // 函数 | ||
} | ||
|
||
function getCounter(): Counter { | ||
function counter(str: string) { | ||
|
||
} | ||
counter.start = 0 | ||
counter.title = '123' | ||
counter.add = function (str: string) { } | ||
|
||
return counter; | ||
} | ||
|
||
let counter: Counter = { | ||
start: 1, | ||
title: '123', | ||
lable: '+', | ||
add: (str1: string)=>{} | ||
} | ||
|
||
interface SubCounter extends Counter { | ||
title: string | ||
add(str: string): void | ||
decerate(num: number): number | ||
} | ||
|
||
class Sub implements SubCounter{ | ||
start = 0 | ||
title = 'abc' | ||
|
||
add(str: string) { | ||
console.log(this.title + str) | ||
} | ||
|
||
decerate(num: number) { | ||
return 1 | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
export default { | ||
run(){ | ||
let sub = new Sub() | ||
|
||
sub.add('-1234') | ||
|
||
console.error(sub.decerate(1)) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
var interface_1 = require("./base/interface"); | ||
interface_1["default"].run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
import main from './base/interface' | ||
|
||
main.run() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "ts-demo", | ||
"version": "1.0.0", | ||
"description": "ts 学习 demo", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"dev": "tsc main.ts & npm run start", | ||
"start": "node main" | ||
}, | ||
"author": "zhangchuan <[email protected]>", | ||
"license": "ISC" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es2017", | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true, | ||
//"noImplicitAny": false, | ||
//"sourceMap": true, | ||
// "allowJs": true, | ||
//"outDir": "target", | ||
"inlineSourceMap": true | ||
//"inlineSources": true | ||
}, | ||
"exclude": [ | ||
"node_modules", | ||
"coverage", | ||
"test" | ||
] | ||
} |