Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): update dependency typescript to v5 #4064

Merged
merged 2 commits into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion e2e/__tests__/custom-compiler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ import { runNpmInstall } from '../utils'

const DIR_NAME = 'custom-compiler'

describe('ttypescript', () => {
/**
* Test disabled after typescript@5 support due to issues on ttypescript.
* Now typescript exports module rather than object namespaces so ttypescript is not working anymore.
* @see https://github.com/kulshekhar/ts-jest/pull/4064#issuecomment-1483937671
*
* Additional info can be found on the following links:
* @see https://github.com/cevek/ttypescript/issues/140
* @see https://github.com/microsoft/TypeScript/issues/52826
*
* Test can be re-enabled after the library supports typescript@5
*/
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('ttypescript', () => {
const TTS_DIR_NAME = 'ttypescript'

beforeAll(() => {
Expand Down
59 changes: 30 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@jest/types": "^29.0.0",
"babel-jest": "^29.0.0",
"jest": "^29.0.0",
"typescript": ">=4.3"
"typescript": ">=4.3 <6"
},
"peerDependenciesMeta": {
"@babel/core": {
Expand Down Expand Up @@ -102,7 +102,6 @@
"@types/lodash.set": "4.x",
"@types/micromatch": "4.x",
"@types/node": "18.15.9",
"@types/node-fetch": "^3.0.3",
"@types/react": "18.x",
"@types/rimraf": "^3.0.2",
"@types/semver": "latest",
Expand Down Expand Up @@ -135,7 +134,7 @@
"lodash.set": "^4.3.2",
"node-fetch": "^3.3.1",
"prettier": "^2.8.7",
"typescript": "~4.9.5"
"typescript": "~5.0.2"
},
"lint-staged": {
"*.{ts,tsx,js,jsx}": [
Expand Down
28 changes: 16 additions & 12 deletions src/legacy/compiler/ts-compiler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { readFileSync } from 'fs'
import { basename, join, normalize } from 'path'

import {
type CompilerOptions,
DiagnosticCategory,
type EmitOutput,
type transpileModule,
type TranspileOutput,
} from 'typescript'
import type { CompilerOptions, EmitOutput, transpileModule, TranspileOutput } from 'typescript'
import * as ts from 'typescript'

import { createConfigSet, makeCompiler } from '../../__helpers__/fakers'
import type { DepGraphInfo } from '../../types'
Expand All @@ -16,6 +11,15 @@ import { Errors, interpolate } from '../../utils/messages'
import { updateOutput } from './compiler-utils'
import { TsCompiler } from './ts-compiler'

jest.mock('typescript', () => {
const actualModule = jest.requireActual('typescript') as typeof ts

return {
__esModule: true,
...actualModule,
}
})

const mockFolder = join(process.cwd(), 'src', '__mocks__')

const baseTsJestConfig = { tsconfig: join(process.cwd(), 'tsconfig.spec.json') }
Expand Down Expand Up @@ -147,7 +151,7 @@ describe('TsCompiler', () => {
outputText: 'var bar = 1',
diagnostics: [
{
category: DiagnosticCategory.Error,
category: ts.DiagnosticCategory.Error,
code: 123,
messageText: 'An error occurs',
file: undefined,
Expand Down Expand Up @@ -550,15 +554,15 @@ describe('TsCompiler', () => {
} as EmitOutput)
const diagnostics = [
{
category: DiagnosticCategory.Error,
category: ts.DiagnosticCategory.Error,
code: 123,
messageText: 'An error occurs',
file: undefined,
start: 0,
length: 1,
},
{
category: DiagnosticCategory.Error,
category: ts.DiagnosticCategory.Error,
code: 456,
messageText: 'An error occurs',
file: undefined,
Expand Down Expand Up @@ -611,15 +615,15 @@ describe('TsCompiler', () => {
})
const diagnostics = [
{
category: DiagnosticCategory.Error,
category: ts.DiagnosticCategory.Error,
code: 123,
messageText: 'An error occurs',
file: undefined,
start: 0,
length: 1,
},
{
category: DiagnosticCategory.Error,
category: ts.DiagnosticCategory.Error,
code: 456,
messageText: 'An error occurs',
file: undefined,
Expand Down
11 changes: 10 additions & 1 deletion src/legacy/config/config-set.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { join, resolve } from 'path'

import type { Transformer } from '@jest/transform'
import { LogLevels, testing } from 'bs-logger'
import ts from 'typescript'
import * as ts from 'typescript'

import { createConfigSet } from '../../__helpers__/fakers'
import { logTargetMock } from '../../__helpers__/mocks'
Expand All @@ -19,6 +19,15 @@ jest.mock('../../utils/backports')
jest.mock('../index')
jest.mock('../../utils/get-package-version')

jest.mock('typescript', () => {
const actualModule = jest.requireActual('typescript') as typeof ts

return {
__esModule: true,
...actualModule,
}
})

const backports = jest.mocked(_backports)

backports.backportJestConfig.mockImplementation((_, config) => ({
Expand Down
6 changes: 4 additions & 2 deletions src/transformers/hoist-jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ export function factory({ configSet }: TsCompilerInstance) {
return visitor
}

type TransformerFunction = _ts.Transformer<_ts.SourceFile>

// returns the transformer factory
return (ctx: _ts.TransformationContext): _ts.Transformer<_ts.SourceFile> =>
return (ctx: _ts.TransformationContext): TransformerFunction =>
logger.wrap({ [LogContexts.logLevel]: LogLevels.debug, call: null }, 'visitSourceFileNode(): hoist jest', (sf) =>
ts.visitNode(sf, createVisitor(ctx, sf)),
)
) as TransformerFunction
}
2 changes: 1 addition & 1 deletion src/utils/version-checkers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const pv = jest.mocked(_pv)
describeChecker(VersionCheckers.jest, 'jest', ['29.0.0'], [undefined, '23.6.0', '24.1.0', '30.0.0'])
describeChecker(VersionCheckers.babelJest, 'babel-jest', ['29.0.0'], [undefined, '23.6.0', '24.1.0', '30.0.0'])
describeChecker(VersionCheckers.babelCore, '@babel/core', ['7.0.0'], [undefined, '6.0.0', '8.0.0'])
describeChecker(VersionCheckers.typescript, 'typescript', ['4.3.0', '4.3.5'], [undefined, '4.2.0', '5.0.0'])
describeChecker(VersionCheckers.typescript, 'typescript', ['4.3.0', '4.3.5', '5.0.0'], [undefined, '4.2.0', '6.0.0'])

function describeChecker(
checker: VersionChecker,
Expand Down
4 changes: 1 addition & 3 deletions src/utils/version-checkers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const logger = rootLogger.child({ namespace: 'versions' })
*/
const enum ExpectedVersions {
Jest = '>=29.0.0 <30',
TypeScript = '>=4.3 <5',
TypeScript = '>=4.3 <6',
BabelJest = '>=29.0.0 <30',
BabelCore = '>=7.0.0-beta.0 <8',
}
Expand Down Expand Up @@ -43,9 +43,7 @@ type CheckVersionAction = 'warn' | 'throw'
* @internal
*/
function checkVersion(name: string, expectedRange: string, action?: Exclude<CheckVersionAction, 'throw'>): boolean
// eslint-disable-next-line no-redeclare
function checkVersion(name: string, expectedRange: string, action: 'throw'): true | never
// eslint-disable-next-line no-redeclare
function checkVersion(
name: string,
expectedRange: string,
Expand Down
16 changes: 8 additions & 8 deletions website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@docusaurus/module-type-aliases": "^2.4.0",
"@tsconfig/docusaurus": "^1.0.7",
"@types/react": "^16.14.24",
"typescript": "~4.9.5"
"typescript": "~5.0.2"
},
"browserslist": {
"production": [
Expand Down