-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ignore js file when the same ts file exists
- Loading branch information
Showing
14 changed files
with
139 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": [ | ||
"eslint-config-egg/typescript", | ||
"eslint-config-egg/lib/rules/enforce-node-prefix" | ||
] | ||
} |
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 @@ | ||
node_modules |
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,4 @@ | ||
export default class FooController { | ||
async render() { | ||
} | ||
} |
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"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = (app) => { | ||
app.router.get('/', async (ctx) => { | ||
ctx.body = 'Hello World'; | ||
}); | ||
}; |
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,5 @@ | ||
export default (app: any) => { | ||
app.router.get('/', async (ctx: any) => { | ||
ctx.body = 'Hello World'; | ||
}); | ||
}; |
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,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = { | ||
keys: 'my secret keys', | ||
}; |
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 @@ | ||
export default { | ||
keys: 'my secret keys', | ||
}; |
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,29 @@ | ||
{ | ||
"name": "helloworld-ts", | ||
"dependencies": { | ||
"egg": "beta" | ||
}, | ||
"devDependencies": { | ||
"@eggjs/bin": "7", | ||
"@eggjs/mock": "6", | ||
"@eggjs/tsconfig": "1", | ||
"@types/mocha": "10", | ||
"@types/node": "22", | ||
"eslint": "8", | ||
"eslint-config-egg": "14", | ||
"typescript": "5" | ||
}, | ||
"scripts": { | ||
"lint": "eslint . --ext .ts", | ||
"dev": "egg-bin dev", | ||
"pretest": "npm run lint -- --fix", | ||
"test": "egg-bin test", | ||
"preci": "npm run lint", | ||
"ci": "egg-bin cov", | ||
"postci": "npm run prepublishOnly && npm run clean", | ||
"clean": "tsc -b --clean", | ||
"prepublishOnly": "npm run clean && tsc" | ||
}, | ||
"private": true, | ||
"repository": "[email protected]:eggjs/examples.git" | ||
} |
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 @@ | ||
import { app } from '@eggjs/mock/bootstrap'; | ||
|
||
describe('example helloworld test', () => { | ||
it('should GET / 200', () => { | ||
return app.httpRequest() | ||
.get('/') | ||
.expect(200) | ||
.expect('Hello World'); | ||
}); | ||
|
||
it('should GET /foo', async () => { | ||
await app.httpRequest() | ||
.get('/foo') | ||
.expect(400) | ||
.expect({ | ||
foo: 'bar', | ||
}); | ||
}); | ||
}); |
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,14 @@ | ||
{ | ||
"extends": "@eggjs/tsconfig", | ||
"compilerOptions": { | ||
"strict": true, | ||
"noImplicitAny": true, | ||
"target": "ES2022", | ||
"module": "NodeNext", | ||
"moduleResolution": "NodeNext", | ||
"declaration": false | ||
}, | ||
"exclude": [ | ||
"test" | ||
] | ||
} |
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,22 @@ | ||
import { strict as assert } from 'node:assert'; | ||
import request from 'supertest'; | ||
import { getFilepath } from './helper.js'; | ||
import { Application } from './fixtures/egg-esm/index.js'; | ||
|
||
describe('test/support-typescript.test.ts', () => { | ||
let app: Application; | ||
before(async () => { | ||
app = new Application({ | ||
baseDir: getFilepath('helloworld-ts'), | ||
type: 'application', | ||
}); | ||
await app.loader.loadAll(); | ||
}); | ||
|
||
it('should ignore *.js when *.ts same file exists', async () => { | ||
const res = await request(app.callback()) | ||
.get('/'); | ||
assert.equal(res.status, 200); | ||
assert.equal(res.text, 'Hello World'); | ||
}); | ||
}); |