Skip to content

Commit

Permalink
Actually default typecheck to false
Browse files Browse the repository at this point in the history
It stopped defaulting true, but all it did was just not set
TS_NODE_TRANSPILE_ONLY to anything, which leaves ts-node defaulting in
typecheck mode.

Re: #912
  • Loading branch information
isaacs committed Sep 29, 2023
1 parent 3451d28 commit 0eeaaf4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
1 change: 1 addition & 0 deletions src/docs/content/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ eleventyNavigation:
## 18.3

- Format React elements as JSX
- Actually default the `typecheck` option to `false` as intended.

## 18.2

Expand Down
6 changes: 3 additions & 3 deletions src/typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export const preload = true
let didSet = false
export const plugin: TapPlugin<{}> = () => {
if (!didSet) {
if (env.TAP_TYPECHECK === '0') {
env.TS_NODE_TRANSPILE_ONLY = '1'
} else if (env.TAP_TYPECHECK === '1') {
if (env.TAP_TYPECHECK === '1') {
env.TS_NODE_TRANSPILE_ONLY = '0'
} else {
env.TS_NODE_TRANSPILE_ONLY = '1'
}
if (env.TAP_TSCONFIG && env.TAP_CWD) {
env.TS_NODE_PROJECT = resolve(env.TAP_CWD, env.TAP_TSCONFIG)
Expand Down
26 changes: 2 additions & 24 deletions src/typescript/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { config, loader } from '../dist/esm/index.js'
t.equal(loader, 'ts-node/esm')
t.matchSnapshot(config)

t.test('no typecheck setting, no effect', async t => {
t.test('typecheck defaults to false', async t => {
const mock = {
'@tapjs/core': t.createMock(core, {
env: {
Expand All @@ -23,7 +23,7 @@ t.test('no typecheck setting, no effect', async t => {
)) as typeof import('../dist/esm/index.js')
plugin(t)
plugin(t)
t.equal(env.TS_NODE_TRANSPILE_ONLY, undefined)
t.equal(env.TS_NODE_TRANSPILE_ONLY, '1')
t.end()
})

Expand All @@ -49,28 +49,6 @@ t.test('typecheck true => transpile only false', async t => {
t.end()
})

t.test('typecheck false => transpile only true', async t => {
const mock = {
'@tapjs/core': t.createMock(core, {
env: {
TS_NODE_TRANSPILE_ONLY: undefined,
TAP_TYPECHECK: '0',
},
}),
}
const {
'@tapjs/core': { env },
} = mock
const { plugin } = (await t.mockImport(
'../dist/esm/index.js',
mock
)) as typeof import('../dist/esm/index.js')
plugin(t)
plugin(t)
t.equal(env.TS_NODE_TRANSPILE_ONLY, '1')
t.end()
})

t.test('--tsconfig option', async t => {
const cwd = t.testdirName
const mock = {
Expand Down

0 comments on commit 0eeaaf4

Please sign in to comment.