Skip to content

Commit

Permalink
feat: TypeScript + VS Code improvements (#33)
Browse files Browse the repository at this point in the history
These are small changes to fix issues noticed while working from this
template on https://github.com/valora-inc/identity-service

- Only use relative imports for now: see
valora-inc/identity-service#29
- VS Code:
- workaround to avoid seeing incorrect errors when working in
`*.test.ts` files
- use TypeScript version from the project instead of the one bundled in
VS Code to avoid seeing incorrect TS issues
  • Loading branch information
jeanregisser authored Oct 14, 2022
1 parent 64efe18 commit 0f5f71a
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
extends: ['@valora/eslint-config-typescript'],
parserOptions: {
project: './tsconfig.eslint.json',
project: './tsconfig.test.json',
},
rules: {
// Maybe move it to @valora/eslint-config-typescript?
Expand Down
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
// Use the project's TypeScript version instead of the one bundled with VS Code
"typescript.tsdk": "node_modules/typescript/lib"
}
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
// Allow absolute imports from the tsconfig baseUrl
moduleDirectories: ['node_modules', '<rootDir>'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
'^.+\\.(ts|tsx)$': ['ts-jest', { tsconfig: 'tsconfig.test.json' }],
},
testPathIgnorePatterns: ['dist'],
setupFiles: ['<rootDir>/jest.setup.js'],
Expand Down
2 changes: 1 addition & 1 deletion src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { main } from 'src'
import { main } from './index'

describe(main, () => {
it("should return 'Hello, world!'", () => {
Expand Down
6 changes: 6 additions & 0 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
// Workaround VS Code only supporting one default tsconfig.json
// Otherwise *.test.ts files would show errors in VS Code
// See https://stackoverflow.com/questions/57044697/how-to-use-different-tsconfig-file-for-test-files-in-vscode
"extends": "../tsconfig.test.json"
}
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "dist",
"baseUrl": ".",
"sourceMap": true,
"strict": true,
"target": "es2021",
Expand Down
File renamed without changes.

0 comments on commit 0f5f71a

Please sign in to comment.