Skip to content

Commit 02f7823

Browse files
authored
chore(util): update tests, types, correct tsconfig build (#1378)
1 parent 293e0c4 commit 02f7823

5 files changed

Lines changed: 28 additions & 20 deletions

File tree

src/compiler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { readFileSync, writeFileSync } from 'fs'
3636
import memoize = require('lodash.memoize')
3737
import mkdirp = require('mkdirp')
3838
import { basename, extname, join, normalize, relative } from 'path'
39+
import { LanguageServiceHost } from 'typescript'
3940

4041
import { ConfigSet } from './config/config-set'
4142
import { MemoryCache, TsCompiler, TypeInfo } from './types'
@@ -133,7 +134,7 @@ export function createCompiler(configs: ConfigSet): TsCompiler {
133134
[LogContexts.logLevel]: LogLevels.trace,
134135
}
135136

136-
const serviceHost = {
137+
const serviceHost: LanguageServiceHost = {
137138
getScriptFileNames: () => Object.keys(memoryCache.versions),
138139
getScriptVersion: (fileName: string) => {
139140
const normalizedFileName = normalize(fileName)

src/shims.d.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,3 @@ declare module 'fast-json-stable-stringify' {
22
const fastJsonStableStringify: (input: any) => string
33
export = fastJsonStableStringify
44
}
5-
6-
declare module 'babel__core' {
7-
import { TransformOptions } from 'babel__core/index'
8-
export * from 'babel__core/index'
9-
export class OptionManager {
10-
init(opt: TransformOptions): TransformOptions
11-
}
12-
}
13-
14-
declare module 'jest-config' {
15-
import 'jest'
16-
export const defaults: jest.InitialOptions
17-
}

src/types.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,3 @@ export interface AstTransformerDesc {
191191
version: number
192192
factory(cs: ConfigSet): TransformerFactory<SourceFile>
193193
}
194-
195-
export interface IPackageJson {
196-
main: string
197-
}

src/util/importer.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,27 @@ describe('babelCore', () => {
121121
`)
122122
})
123123
})
124+
125+
describe('babelJest', () => {
126+
it('should be babel-jest', () => {
127+
modules = {
128+
'babel-jest': () => 'babel-jest',
129+
}
130+
expect(new Importer().babelJest(fakers.importReason())).toBe('babel-jest')
131+
})
132+
it('should fail with correct error message', () => {
133+
expect(() => new Importer().babelJest(fakers.importReason())).toThrowErrorMatchingInlineSnapshot(`
134+
"Unable to load the module \\"babel-jest\\". [[BECAUSE]] To fix it:
135+
↳ install \\"babel-jest\\": \`npm i -D babel-jest\` (or \`yarn add --dev babel-jest\`)"
136+
`)
137+
})
138+
})
139+
140+
describe('typescript', () => {
141+
it('should be typescript', () => {
142+
modules = {
143+
typescript: () => 'typescript',
144+
}
145+
expect(new Importer().typescript(fakers.importReason(), 'typescript')).toBe('typescript')
146+
})
147+
})

tsconfig.build.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
"declaration": true,
99
"stripInternal": true,
1010
"outDir": "dist",
11-
"rootDir": "src",
11+
"rootDir": "src"
1212
},
1313
"include": ["src"],
1414
"exclude": [
1515
"**/*.spec.ts",
1616
"**/*.test.ts",
17-
"**/__*__",
17+
"**/__*__"
1818
]
1919
}

0 commit comments

Comments
 (0)