Skip to content

Commit bcd9bd1

Browse files
authored
Merge pull request #2936 from plotly/feature/support-ts-5.5
Add Support for TypeScript 5.5
2 parents 64ed7fc + 5795353 commit bcd9bd1

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
77
## Added
88

99
- [#2881](https://github.com/plotly/dash/pull/2881) Add outputs_list to window.dash_clientside.callback_context. Fixes [#2877](https://github.com/plotly/dash/issues/2877).
10+
- [#2936](https://github.com/plotly/dash/pull/2936) Adds support for TypeScript 5.5+.
1011

1112
## Fixed
1213

dash/extract-meta.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ const reservedPatterns = args[1]
2121
? args[1].split('|').map(part => new RegExp(part))
2222
: [];
2323

24-
let tsconfig = {};
25-
2624
function help() {
2725
console.error('usage: ');
2826
console.error(
@@ -36,24 +34,14 @@ if (!src.length) {
3634
process.exit(1);
3735
}
3836

39-
if (fs.existsSync('tsconfig.json')) {
40-
tsconfig = JSON.parse(fs.readFileSync('tsconfig.json')).compilerOptions;
41-
// Map moduleResolution to the appropriate enum.
42-
switch (tsconfig.moduleResolution) {
43-
case 'node':
44-
tsconfig.moduleResolution = ts.ModuleResolutionKind.NodeJs;
45-
break;
46-
case 'node16':
47-
tsconfig.moduleResolution = ts.ModuleResolutionKind.Node16;
48-
break;
49-
case 'nodenext':
50-
tsconfig.moduleResolution = ts.ModuleResolutionKind.NodeNext;
51-
break;
52-
case 'classic':
53-
tsconfig.moduleResolution = ts.ModuleResolutionKind.Classic;
54-
break;
55-
default:
56-
break;
37+
function getTsConfigCompilerOptions() {
38+
// Since extract-meta can be run on JavaScript sources, if trying to get the
39+
// config doesn't work, we can fall back gracefully.
40+
try {
41+
const tsconfig = ts.getParsedCommandLineOfConfigFile('tsconfig.json', { esModuleInterop: true }, ts.sys);
42+
return tsconfig?.options ?? {};
43+
} catch {
44+
return {};
5745
}
5846
}
5947

@@ -204,7 +192,7 @@ function gatherComponents(sources, components = {}) {
204192
return components;
205193
}
206194

207-
const program = ts.createProgram(filepaths, {...tsconfig, esModuleInterop: true});
195+
const program = ts.createProgram(filepaths, getTsConfigCompilerOptions());
208196
const checker = program.getTypeChecker();
209197

210198
const coerceValue = t => {

0 commit comments

Comments
 (0)