Skip to content

Commit 0e468c9

Browse files
feat(typescript-estree): add package version to ts version warning (typescript-eslint#10343)
* feat(typescript-estree): add package version to ts version warning * restore original phrase and fix package name typo * update warn about ts version message * correct message version * Update docs/packages/Parser.mdx --------- Co-authored-by: Josh Goldberg ✨ <[email protected]>
1 parent ae627e9 commit 0e468c9

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

docs/packages/Parser.mdx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,9 @@ This option allows you to toggle the warning that the parser will give you if yo
423423
424424
WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.
425425
426-
You may find that it works just fine, or you may not.
427-
428-
SUPPORTED TYPESCRIPT VERSIONS: >=3.3.1 <5.1.0
429-
430-
YOUR TYPESCRIPT VERSION: 5.1.3
426+
* @typescript-eslint/typescript-estree version: 8.15.0
427+
* Supported TypeScript versions: >=4.7.4 <5.7.0
428+
* Your TypeScript version: 5.7.1
431429
432430
Please only submit bug reports when using the officially supported version.
433431

packages/typescript-estree/src/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,5 @@ export type {
1919
export { simpleTraverse } from './simple-traverse';
2020
export * from './ts-estree';
2121
export { typescriptVersionIsAtLeast } from './version-check';
22+
export { version } from './version';
2223
export { withoutProjectParserOptions } from './withoutProjectParserOptions';
23-
24-
// note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder
25-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
26-
export const version: string = require('../package.json').version;

packages/typescript-estree/src/parseSettings/warnAboutTSVersion.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import * as ts from 'typescript';
33

44
import type { ParseSettings } from './index';
55

6+
import { version as TYPESCRIPT_ESTREE_VERSION } from '../version';
7+
68
/**
79
* This needs to be kept in sync with package.json in the typescript-eslint monorepo
810
*/
@@ -38,13 +40,17 @@ export function warnAboutTSVersion(
3840
const border = '=============';
3941
const versionWarning = [
4042
border,
43+
'\n',
4144
'WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.',
42-
'You may find that it works just fine, or you may not.',
43-
`SUPPORTED TYPESCRIPT VERSIONS: ${SUPPORTED_TYPESCRIPT_VERSIONS}`,
44-
`YOUR TYPESCRIPT VERSION: ${ACTIVE_TYPESCRIPT_VERSION}`,
45+
'\n',
46+
`* @typescript-eslint/typescript-estree version: ${TYPESCRIPT_ESTREE_VERSION}`,
47+
`* Supported TypeScript versions: ${SUPPORTED_TYPESCRIPT_VERSIONS}`,
48+
`* Your TypeScript version: ${ACTIVE_TYPESCRIPT_VERSION}`,
49+
'\n',
4550
'Please only submit bug reports when using the officially supported version.',
51+
'\n',
4652
border,
47-
].join('\n\n');
53+
].join('\n');
4854

4955
parseSettings.log(versionWarning);
5056
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder
2+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
3+
export const version: string = require('../package.json').version;

packages/typescript-estree/tests/lib/warn-on-unsupported-ts.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('Warn on unsupported TypeScript version', () => {
2727
parser.parse('');
2828
expect(console.log).toHaveBeenCalledWith(
2929
expect.stringContaining(
30-
'WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree',
30+
'WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.',
3131
),
3232
);
3333
});

0 commit comments

Comments
 (0)