Skip to content

Commit eab2e98

Browse files
committed
tests: update internal api in test #72
1 parent 99ff47c commit eab2e98

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"compilerOptions": {
33
"baseUrl": ".",
4-
"extends": "./59-tsconfig.paths.json",
54
"paths": {
65
"alias/*": [ "target/*" ]
76
}
8-
}
7+
},
8+
"extends": "./59-tsconfig.paths.json"
99
}

packages/react-app-alias/__tests__/59-tsconfig.paths.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"compilerOptions": {
3-
"baseUrl": ".",
43
"paths": {
54
"alias-paths/*": [ "target-paths/*" ]
65
}

packages/react-app-alias/__tests__/react-app-alias.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
'use strict';
22
const path = require('path')
3-
const {configPathsRaw} = require('../src');
3+
const {configPathsRaw, readConfig} = require('../src');
44

55
describe('react-app-alias', () => {
66
test.todo('tested by tests in projects in example folder');
77
});
88

99
describe('extends section of tsconfig on detect config file stage', () => {
1010
test('read both file and extends', () => {
11-
const paths = configPathsRaw(path.resolve(__dirname, './59-tsconfig.json'))
11+
const conf = readConfig(path.resolve(__dirname, './59-tsconfig.json'))
12+
const paths = configPathsRaw(conf)
1213
expect(paths['alias/*'][0]).toBe('target/*');
1314
expect(paths['alias-paths/*'][0]).toBe('target-paths/*');
1415
});

packages/react-app-alias/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ function configPathsRaw(conf) {
152152
const confPaths = conf.compilerOptions && conf.compilerOptions.paths ?
153153
conf.compilerOptions.paths : {}
154154

155-
const ext = conf.extends
155+
const ext = conf.extends || {}
156156
const extPaths = ext.compilerOptions && ext.compilerOptions.paths ?
157157
ext.compilerOptions.paths : {}
158158

159159
if(typeof confPaths !== 'object')
160160
throw Error(`react-app-alias:configPathsRaw: compilerOptions.paths must be object`)
161161
if(typeof extPaths !== 'object')
162162
throw Error(`react-app-alias:configPathsRaw: compilerOptions.extends->compilerOptions.paths must be object`)
163-
163+
164164
return {
165165
...confPaths,
166166
...extPaths,

0 commit comments

Comments
 (0)