-
-
Notifications
You must be signed in to change notification settings - Fork 537
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update bundled
transpileModule
implementation to match latest TS co…
…debase (#1973) * empty initial commit * Update bundled `transpileModule` implementation to match latest TS 5.0 codebase * Add test; move transpile-only tests to their own file
- Loading branch information
Showing
4 changed files
with
81 additions
and
28 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,51 @@ | ||
import { createExec } from './exec-helpers'; | ||
import { ctxTsNode, tsSupportsVerbatimModuleSyntax } from './helpers'; | ||
import { CMD_TS_NODE_WITH_PROJECT_FLAG } from './helpers/command-lines'; | ||
import { TEST_DIR } from './helpers/paths'; | ||
import { expect, context } from './testlib'; | ||
|
||
const test = context(ctxTsNode); | ||
|
||
const exec = createExec({ | ||
cwd: TEST_DIR, | ||
}); | ||
|
||
test('should support transpile only mode', async () => { | ||
const r = await exec( | ||
`${CMD_TS_NODE_WITH_PROJECT_FLAG} --transpile-only -pe "x"` | ||
); | ||
if (r.err === null) { | ||
throw new Error('Command was expected to fail, but it succeeded.'); | ||
} | ||
|
||
expect(r.err.message).toMatch('ReferenceError: x is not defined'); | ||
}); | ||
|
||
test('should throw error even in transpileOnly mode', async () => { | ||
const r = await exec( | ||
`${CMD_TS_NODE_WITH_PROJECT_FLAG} --transpile-only -pe "console."` | ||
); | ||
if (r.err === null) { | ||
throw new Error('Command was expected to fail, but it succeeded.'); | ||
} | ||
|
||
expect(r.err.message).toMatch('error TS1003: Identifier expected'); | ||
}); | ||
|
||
test.suite( | ||
'verbatimModuleSyntax w/transpileOnly should not raise configuration diagnostic', | ||
(test) => { | ||
test.if(tsSupportsVerbatimModuleSyntax); | ||
test('test', async (t) => { | ||
// Mixing verbatimModuleSyntax w/transpileOnly | ||
// https://github.com/TypeStrong/ts-node/issues/1971 | ||
// We should *not* get: | ||
// "error TS5104: Option 'isolatedModules' is redundant and cannot be specified with option 'verbatimModuleSyntax'." | ||
const service = t.context.tsNodeUnderTest.create({ | ||
transpileOnly: true, | ||
compilerOptions: { verbatimModuleSyntax: true }, | ||
}); | ||
service.compile('const foo: string = 123', 'module.ts'); | ||
}); | ||
} | ||
); |
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