Skip to content

Commit

Permalink
move getOutputTranspileOnly back where it used to be (#1056)
Browse files Browse the repository at this point in the history
* move getOutputTranspileOnly back where it used to be

* fix

* remove overrideCompilerOptions argument
  • Loading branch information
cspotcode committed May 25, 2020
1 parent 1f5b1e0 commit 866bce6
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,20 +487,6 @@ export function create (rawOptions: CreateOptions = {}): Register {
let getOutput: (code: string, fileName: string) => SourceOutput
let getTypeInfo: (_code: string, _fileName: string, _position: number) => TypeInfo

const getOutputTranspileOnly = (code: string, fileName: string, overrideCompilerOptions?: Partial<_ts.CompilerOptions>): SourceOutput => {
const result = ts.transpileModule(code, {
fileName,
compilerOptions: overrideCompilerOptions ? { ...config.options, ...overrideCompilerOptions } : config.options,
reportDiagnostics: true,
transformers: transformers as Exclude<typeof transformers, Function>
})

const diagnosticList = filterDiagnostics(result.diagnostics || [], ignoreDiagnostics)
if (diagnosticList.length) reportTSError(diagnosticList)

return [result.outputText, result.sourceMapText as string]
}

// Use full language services when the fast option is disabled.
if (!transpileOnly) {
const fileContents = new Map<string, string>()
Expand Down Expand Up @@ -790,7 +776,19 @@ export function create (rawOptions: CreateOptions = {}): Register {
throw new TypeError('Transformers function is unavailable in "--transpile-only"')
}

getOutput = getOutputTranspileOnly
getOutput = (code: string, fileName: string): SourceOutput => {
const result = ts.transpileModule(code, {
fileName,
compilerOptions: config.options,
reportDiagnostics: true,
transformers: transformers
})

const diagnosticList = filterDiagnostics(result.diagnostics || [], ignoreDiagnostics)
if (diagnosticList.length) reportTSError(diagnosticList)

return [result.outputText, result.sourceMapText as string]
}

getTypeInfo = () => {
throw new TypeError('Type information is unavailable in "--transpile-only"')
Expand Down

0 comments on commit 866bce6

Please sign in to comment.