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

Add Support for TypeScript 5.5 #2936

Merged
merged 5 commits into from
Aug 23, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## Added

- [#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).
- [#2936](https://github.com/plotly/dash/pull/2936) Adds support for TypeScript 5.5+.

## Fixed

Expand Down
30 changes: 9 additions & 21 deletions dash/extract-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ const reservedPatterns = args[1]
? args[1].split('|').map(part => new RegExp(part))
: [];

let tsconfig = {};

function help() {
console.error('usage: ');
console.error(
Expand All @@ -36,24 +34,14 @@ if (!src.length) {
process.exit(1);
}

if (fs.existsSync('tsconfig.json')) {
tsconfig = JSON.parse(fs.readFileSync('tsconfig.json')).compilerOptions;
// Map moduleResolution to the appropriate enum.
switch (tsconfig.moduleResolution) {
case 'node':
tsconfig.moduleResolution = ts.ModuleResolutionKind.NodeJs;
break;
case 'node16':
tsconfig.moduleResolution = ts.ModuleResolutionKind.Node16;
break;
case 'nodenext':
tsconfig.moduleResolution = ts.ModuleResolutionKind.NodeNext;
break;
case 'classic':
tsconfig.moduleResolution = ts.ModuleResolutionKind.Classic;
break;
default:
break;
function getTsConfigCompilerOptions() {
// Since extract-meta can be run on JavaScript sources, if trying to get the
// config doesn't work, we can fall back gracefully.
try {
const tsconfig = ts.getParsedCommandLineOfConfigFile('tsconfig.json', { esModuleInterop: true }, ts.sys);
return tsconfig?.options ?? {};
} catch {
return {};
}
}

Expand Down Expand Up @@ -204,7 +192,7 @@ function gatherComponents(sources, components = {}) {
return components;
}

const program = ts.createProgram(filepaths, {...tsconfig, esModuleInterop: true});
const program = ts.createProgram(filepaths, getTsConfigCompilerOptions());
const checker = program.getTypeChecker();

const coerceValue = t => {
Expand Down