-
Notifications
You must be signed in to change notification settings - Fork 54
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
Showing
21 changed files
with
216 additions
and
13 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
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
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
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
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
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
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,28 @@ | ||
'use strict'; | ||
|
||
require('ts-node').register({ | ||
typeCheck: true, | ||
compilerOptions: { | ||
target: 'es2017', | ||
module: 'commonjs', | ||
strict: true, | ||
moduleResolution: 'node', | ||
noImplicitAny: false, | ||
experimentalDecorators: true, | ||
emitDecoratorMetadata: true, | ||
charset: 'utf8', | ||
allowJs: false, | ||
pretty: true, | ||
noEmitOnError: false, | ||
noUnusedLocals: true, | ||
noUnusedParameters: true, | ||
allowUnreachableCode: false, | ||
allowUnusedLabels: false, | ||
strictPropertyInitialization: false, | ||
noFallthroughCasesInSwitch: true, | ||
skipLibCheck: true, | ||
skipDefaultLibCheck: true, | ||
inlineSourceMap: true, | ||
importHelpers: true, | ||
}, | ||
}); |
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
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,3 @@ | ||
'use strict'; | ||
|
||
console.log('hey, you require me by --require'); |
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,6 @@ | ||
'use strict'; | ||
|
||
|
||
module.exports = app => { | ||
app.logger.info('###', require('./test.ts').default.name); | ||
}; |
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,3 @@ | ||
'use strict'; | ||
|
||
exports.key = '12345'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,6 @@ | ||
{ | ||
"name": "ts", | ||
"egg": { | ||
"framework": "aliyun-egg" | ||
} | ||
} |
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,3 @@ | ||
'use strict'; | ||
|
||
export default { name: 'egg from ts' }; |
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,7 @@ | ||
'use strict'; | ||
|
||
describe('a.test.js', () => { | ||
it('should success', () => { | ||
throw 'should not load js files'; | ||
}); | ||
}); |
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,3 @@ | ||
'use strict'; | ||
|
||
export default { name: 'egg from ts' }; |
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,17 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
|
||
describe('typescript.test.ts', () => { | ||
it('should success', () => { | ||
const obj = require('./sub'); | ||
console.log('###', obj.default.name); | ||
assert(obj.default.name === 'egg from ts'); | ||
}); | ||
|
||
it('should fail', () => { | ||
const obj = require('./sub'); | ||
console.log('###', obj.default.name); | ||
assert(obj.default.name === 'wrong assert ts'); | ||
}); | ||
}); |
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
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
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,34 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const coffee = require('coffee'); | ||
const mm = require('mm'); | ||
|
||
describe('test/ts.test.js', () => { | ||
const eggBin = require.resolve('../bin/egg-bin'); | ||
const cwd = path.join(__dirname, './fixtures/ts'); | ||
|
||
afterEach(mm.restore); | ||
|
||
it('should support ts', () => { | ||
mm(process.env, 'NODE_ENV', 'development'); | ||
return coffee.fork(eggBin, [ 'dev', '--typescript' ], { cwd }) | ||
.debug() | ||
.expect('stdout', /### egg from ts/) | ||
.expect('stdout', /options.typescript=true/) | ||
.expect('stdout', /egg started/) | ||
.expect('code', 0) | ||
.end(); | ||
}); | ||
|
||
it('should support ts test', () => { | ||
mm(process.env, 'NODE_ENV', 'development'); | ||
return coffee.fork(eggBin, [ 'test', '--typescript' ], { cwd }) | ||
.debug() | ||
.notExpect('stdout', /false == true/) | ||
.notExpect('stdout', /should not load js files/) | ||
.expect('stdout', /--- \[string\] 'wrong assert ts'/) | ||
.expect('code', 1) | ||
.end(); | ||
}); | ||
}); |