Skip to content

Commit d538aed

Browse files
authored
[ui] TS native preview (#32990)
Add the TypeScript native preview to a few JS projects in `dagster`, along with a `tsgo` script to run it. https://devblogs.microsoft.com/typescript/progress-on-typescript-7-december-2025/ This will let us start trying it out a bit before everyone switches to use it, using it in builds, etc. I had to iron out a couple of issues. Will comment inline. ## Test Plan For each project with `tsgo` added, run `yarn tsgo`. `make tsgo` from `dagster-ui`.
1 parent 4515040 commit d538aed

File tree

8 files changed

+181
-74
lines changed

8 files changed

+181
-74
lines changed

js_modules/dagster-ui/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ generate-perms:
1010
ts:
1111
yarn workspace @dagster-io/app-oss ts && yarn workspace @dagster-io/ui-core ts && yarn workspace @dagster-io/ui-components ts
1212

13+
tsgo:
14+
yarn workspace @dagster-io/app-oss tsgo && yarn workspace @dagster-io/ui-core tsgo && yarn workspace @dagster-io/ui-components tsgo
15+
1316
lint:
1417
yarn workspace @dagster-io/app-oss lint && yarn workspace @dagster-io/ui-core lint && yarn workspace @dagster-io/ui-components lint
1518

js_modules/dagster-ui/packages/app-oss/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@types/webpack-bundle-analyzer": "^4",
4141
"@typescript-eslint/eslint-plugin": "^8.44.0",
4242
"@typescript-eslint/parser": "^8.44.0",
43+
"@typescript/native-preview": "^7.0.0-dev.20251204.1",
4344
"eslint": "^8.57.1",
4445
"eslint-plugin-import": "^2.31.0",
4546
"eslint-plugin-jest": "^26.4.6",
@@ -60,6 +61,7 @@
6061
"lint:ci": "eslint src/ --ext=.tsx,.ts,.js -c .eslintrc.js",
6162
"test": "jest",
6263
"ts": "tsc -p .",
64+
"tsgo": "tsgo -p .",
6365
"analyze": "webpack-bundle-analyzer '.next/webpack-stats.json'"
6466
},
6567
"browserslist": {

js_modules/dagster-ui/packages/dg-docs-components/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"ts": "tsc -p .",
8+
"tsgo": "tsgo -p .",
89
"lint": "eslint ."
910
},
1011
"dependencies": {
@@ -22,6 +23,7 @@
2223
"@eslint/js": "^9.31.0",
2324
"@types/node": "^22.13.13",
2425
"@types/react": "^18.3.9",
26+
"@typescript/native-preview": "^7.0.0-dev.20251204.1",
2527
"eslint": "^9.31.0",
2628
"eslint-config-prettier": "^10.1.1",
2729
"eslint-plugin-prettier": "^5.2.5",

js_modules/dagster-ui/packages/dg-docs-site/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"start": "next start",
99
"lint": "next lint",
1010
"lint:fix": "next lint --fix",
11-
"ts": "tsc -p ."
11+
"ts": "tsc -p .",
12+
"tsgo": "tsgo -p ."
1213
},
1314
"dependencies": {
1415
"@dagster-io/dg-docs-components": "workspace:*",
@@ -27,6 +28,7 @@
2728
"@types/node": "^20",
2829
"@types/react": "^18.3.9",
2930
"@types/react-dom": "^18.3.0",
31+
"@typescript/native-preview": "^7.0.0-dev.20251204.1",
3032
"eslint": "^9.31.0",
3133
"eslint-config-next": "15.2.1",
3234
"eslint-config-prettier": "^10.1.1",

js_modules/dagster-ui/packages/ui-components/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"jest": "jest",
2020
"jest-all-silent": "yarn jest --silent --watchAll=false --maxWorkers=50%",
2121
"ts": "tsc -p .",
22+
"tsgo": "tsgo -p .",
2223
"storybook": "storybook dev -p 6006",
2324
"build-storybook": "storybook build"
2425
},
@@ -80,6 +81,7 @@
8081
"@types/react-is": "^18.3.0",
8182
"@types/styled-components": "^5.1.26",
8283
"@types/testing-library__jest-dom": "^5.14.2",
84+
"@typescript/native-preview": "^7.0.0-dev.20251203.1",
8385
"babel-jest": "^27.4.6",
8486
"babel-loader": "^9.1.2",
8587
"babel-plugin-macros": "^3.1.0",

js_modules/dagster-ui/packages/ui-core/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"lint": "eslint src/ --ext=.tsx,.ts,.js,.graphql --fix -c .eslintrc.js",
1313
"lint:ci": "eslint src/ --ext=.tsx,.ts,.js,.graphql -c .eslintrc.js",
1414
"ts": "tsc -p .",
15+
"tsgo": "tsgo -p .",
1516
"ts:workers": "tsc -p ./tsconfig.workers.json",
1617
"generate-graphql": "ts-node -O '{\"module\": \"commonjs\"}' ./src/scripts/generateGraphQLTypes.ts",
1718
"generate-perms": "ts-node -O '{\"module\": \"commonjs\"}' ./src/scripts/generatePermissions.ts",
@@ -143,6 +144,7 @@
143144
"@types/ws": "^6.0.3",
144145
"@typescript-eslint/eslint-plugin": "^8.44.0",
145146
"@typescript-eslint/parser": "^8.44.0",
147+
"@typescript/native-preview": "^7.0.0-dev.20251203.1",
146148
"antlr4ts-cli": "0.5.0-alpha.4",
147149
"babel-jest": "^29.7.0",
148150
"babel-loader": "9.1.2",

js_modules/dagster-ui/packages/ui-core/src/testing/mocking.ts

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {MockedResponse} from '@apollo/client/testing';
2-
import deepmerge from 'deepmerge';
32
import {GraphQLError} from 'graphql';
43

54
import {DocumentNode, OperationVariables} from '../apollo-client';
@@ -84,78 +83,6 @@ export function getMockResultFn<T>(mock: MockedResponse<T>) {
8483
return mockFn;
8584
}
8685

87-
/**
88-
* Merges result data for queries of the same type.
89-
* See mocking.test.ts for example usage
90-
*/
91-
export function mergeMockQueries<T extends Record<string, any>>(
92-
defaultData: MockedResponse<T>,
93-
...queries: Array<MockedResponse<T>>
94-
): MockedResponse<T> {
95-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
96-
let mergedResult = resultData(queries[0]!.result, queries[0]!.request.variables);
97-
for (let i = 1; i < queries.length; i++) {
98-
mergedResult = deepmerge(
99-
mergedResult,
100-
removeDefaultValues(
101-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
102-
resultData(defaultData.result!),
103-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
104-
resultData(queries[i]!.result!, queries[i]?.request.variables),
105-
),
106-
);
107-
}
108-
return {
109-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
110-
...queries[0]!,
111-
result: mergedResult,
112-
};
113-
}
114-
115-
function resultData<T>(result: MockedResponse<T>['result'], variables: Record<string, any> = {}) {
116-
if (result instanceof Function) {
117-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
118-
return result(variables)!;
119-
} else {
120-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
121-
return result!;
122-
}
123-
}
124-
125-
function removeDefaultValues<T extends Record<string | number, any> | Array<any>>(
126-
defaultData: T,
127-
data: T,
128-
): T {
129-
const dataWithoutDefaultValues: Partial<T> =
130-
defaultData instanceof Array ? ([...(data as any)] as T) : {...data}; // Use a copy of 'data'
131-
132-
if (data instanceof Object) {
133-
Object.keys(defaultData).forEach((key: any) => {
134-
if (key in data && key in defaultData) {
135-
if (data[key] === defaultData[key]) {
136-
delete dataWithoutDefaultValues[key];
137-
} else {
138-
if (data[key] instanceof Object) {
139-
const dataKey = key as keyof T; // Use a type assertion to narrow the type of key
140-
const result = removeDefaultValues(defaultData[key], data[key]);
141-
if (result) {
142-
dataWithoutDefaultValues[dataKey] = result;
143-
} else {
144-
delete dataWithoutDefaultValues[dataKey];
145-
}
146-
} else {
147-
dataWithoutDefaultValues[key] = data[key];
148-
}
149-
}
150-
}
151-
});
152-
} else if (data === defaultData) {
153-
return undefined as any; // Return 'undefined' with 'any' type for consistency
154-
}
155-
156-
return dataWithoutDefaultValues as T; // Cast to the original type 'T'
157-
}
158-
15986
let nativeGBRC: any;
16087

16188
/* simulate getBoundingCLientRect returning a > 0x0 size, important for

js_modules/dagster-ui/yarn.lock

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,6 +1845,7 @@ __metadata:
18451845
"@types/webpack-bundle-analyzer": "npm:^4"
18461846
"@typescript-eslint/eslint-plugin": "npm:^8.44.0"
18471847
"@typescript-eslint/parser": "npm:^8.44.0"
1848+
"@typescript/native-preview": "npm:^7.0.0-dev.20251204.1"
18481849
eslint: "npm:^8.57.1"
18491850
eslint-config-next: "npm:^13.5.3"
18501851
eslint-plugin-import: "npm:^2.31.0"
@@ -1889,6 +1890,7 @@ __metadata:
18891890
"@eslint/js": "npm:^9.31.0"
18901891
"@types/node": "npm:^22.13.13"
18911892
"@types/react": "npm:^18.3.9"
1893+
"@typescript/native-preview": "npm:^7.0.0-dev.20251204.1"
18921894
clsx: "npm:^2.1.1"
18931895
eslint: "npm:^9.31.0"
18941896
eslint-config-prettier: "npm:^10.1.1"
@@ -1923,6 +1925,7 @@ __metadata:
19231925
"@types/node": "npm:^20"
19241926
"@types/react": "npm:^18.3.9"
19251927
"@types/react-dom": "npm:^18.3.0"
1928+
"@typescript/native-preview": "npm:^7.0.0-dev.20251204.1"
19261929
clsx: "npm:^2.1.1"
19271930
eslint: "npm:^9.31.0"
19281931
eslint-config-next: "npm:15.2.1"
@@ -2010,6 +2013,7 @@ __metadata:
20102013
"@types/react-is": "npm:^18.3.0"
20112014
"@types/styled-components": "npm:^5.1.26"
20122015
"@types/testing-library__jest-dom": "npm:^5.14.2"
2016+
"@typescript/native-preview": "npm:^7.0.0-dev.20251203.1"
20132017
amator: "npm:^1.1.0"
20142018
babel-jest: "npm:^27.4.6"
20152019
babel-loader: "npm:^9.1.2"
@@ -2113,6 +2117,7 @@ __metadata:
21132117
"@types/ws": "npm:^6.0.3"
21142118
"@typescript-eslint/eslint-plugin": "npm:^8.44.0"
21152119
"@typescript-eslint/parser": "npm:^8.44.0"
2120+
"@typescript/native-preview": "npm:^7.0.0-dev.20251203.1"
21162121
"@vx/shape": "npm:^0.0.192"
21172122
amator: "npm:^1.1.0"
21182123
ansi-to-react: "npm:^5.1.0"
@@ -5996,6 +6001,168 @@ __metadata:
59966001
languageName: node
59976002
linkType: hard
59986003

6004+
"@typescript/native-preview-darwin-arm64@npm:7.0.0-dev.20251203.1":
6005+
version: 7.0.0-dev.20251203.1
6006+
resolution: "@typescript/native-preview-darwin-arm64@npm:7.0.0-dev.20251203.1"
6007+
conditions: os=darwin & cpu=arm64
6008+
languageName: node
6009+
linkType: hard
6010+
6011+
"@typescript/native-preview-darwin-arm64@npm:7.0.0-dev.20251204.1":
6012+
version: 7.0.0-dev.20251204.1
6013+
resolution: "@typescript/native-preview-darwin-arm64@npm:7.0.0-dev.20251204.1"
6014+
conditions: os=darwin & cpu=arm64
6015+
languageName: node
6016+
linkType: hard
6017+
6018+
"@typescript/native-preview-darwin-x64@npm:7.0.0-dev.20251203.1":
6019+
version: 7.0.0-dev.20251203.1
6020+
resolution: "@typescript/native-preview-darwin-x64@npm:7.0.0-dev.20251203.1"
6021+
conditions: os=darwin & cpu=x64
6022+
languageName: node
6023+
linkType: hard
6024+
6025+
"@typescript/native-preview-darwin-x64@npm:7.0.0-dev.20251204.1":
6026+
version: 7.0.0-dev.20251204.1
6027+
resolution: "@typescript/native-preview-darwin-x64@npm:7.0.0-dev.20251204.1"
6028+
conditions: os=darwin & cpu=x64
6029+
languageName: node
6030+
linkType: hard
6031+
6032+
"@typescript/native-preview-linux-arm64@npm:7.0.0-dev.20251203.1":
6033+
version: 7.0.0-dev.20251203.1
6034+
resolution: "@typescript/native-preview-linux-arm64@npm:7.0.0-dev.20251203.1"
6035+
conditions: os=linux & cpu=arm64
6036+
languageName: node
6037+
linkType: hard
6038+
6039+
"@typescript/native-preview-linux-arm64@npm:7.0.0-dev.20251204.1":
6040+
version: 7.0.0-dev.20251204.1
6041+
resolution: "@typescript/native-preview-linux-arm64@npm:7.0.0-dev.20251204.1"
6042+
conditions: os=linux & cpu=arm64
6043+
languageName: node
6044+
linkType: hard
6045+
6046+
"@typescript/native-preview-linux-arm@npm:7.0.0-dev.20251203.1":
6047+
version: 7.0.0-dev.20251203.1
6048+
resolution: "@typescript/native-preview-linux-arm@npm:7.0.0-dev.20251203.1"
6049+
conditions: os=linux & cpu=arm
6050+
languageName: node
6051+
linkType: hard
6052+
6053+
"@typescript/native-preview-linux-arm@npm:7.0.0-dev.20251204.1":
6054+
version: 7.0.0-dev.20251204.1
6055+
resolution: "@typescript/native-preview-linux-arm@npm:7.0.0-dev.20251204.1"
6056+
conditions: os=linux & cpu=arm
6057+
languageName: node
6058+
linkType: hard
6059+
6060+
"@typescript/native-preview-linux-x64@npm:7.0.0-dev.20251203.1":
6061+
version: 7.0.0-dev.20251203.1
6062+
resolution: "@typescript/native-preview-linux-x64@npm:7.0.0-dev.20251203.1"
6063+
conditions: os=linux & cpu=x64
6064+
languageName: node
6065+
linkType: hard
6066+
6067+
"@typescript/native-preview-linux-x64@npm:7.0.0-dev.20251204.1":
6068+
version: 7.0.0-dev.20251204.1
6069+
resolution: "@typescript/native-preview-linux-x64@npm:7.0.0-dev.20251204.1"
6070+
conditions: os=linux & cpu=x64
6071+
languageName: node
6072+
linkType: hard
6073+
6074+
"@typescript/native-preview-win32-arm64@npm:7.0.0-dev.20251203.1":
6075+
version: 7.0.0-dev.20251203.1
6076+
resolution: "@typescript/native-preview-win32-arm64@npm:7.0.0-dev.20251203.1"
6077+
conditions: os=win32 & cpu=arm64
6078+
languageName: node
6079+
linkType: hard
6080+
6081+
"@typescript/native-preview-win32-arm64@npm:7.0.0-dev.20251204.1":
6082+
version: 7.0.0-dev.20251204.1
6083+
resolution: "@typescript/native-preview-win32-arm64@npm:7.0.0-dev.20251204.1"
6084+
conditions: os=win32 & cpu=arm64
6085+
languageName: node
6086+
linkType: hard
6087+
6088+
"@typescript/native-preview-win32-x64@npm:7.0.0-dev.20251203.1":
6089+
version: 7.0.0-dev.20251203.1
6090+
resolution: "@typescript/native-preview-win32-x64@npm:7.0.0-dev.20251203.1"
6091+
conditions: os=win32 & cpu=x64
6092+
languageName: node
6093+
linkType: hard
6094+
6095+
"@typescript/native-preview-win32-x64@npm:7.0.0-dev.20251204.1":
6096+
version: 7.0.0-dev.20251204.1
6097+
resolution: "@typescript/native-preview-win32-x64@npm:7.0.0-dev.20251204.1"
6098+
conditions: os=win32 & cpu=x64
6099+
languageName: node
6100+
linkType: hard
6101+
6102+
"@typescript/native-preview@npm:^7.0.0-dev.20251203.1":
6103+
version: 7.0.0-dev.20251203.1
6104+
resolution: "@typescript/native-preview@npm:7.0.0-dev.20251203.1"
6105+
dependencies:
6106+
"@typescript/native-preview-darwin-arm64": "npm:7.0.0-dev.20251203.1"
6107+
"@typescript/native-preview-darwin-x64": "npm:7.0.0-dev.20251203.1"
6108+
"@typescript/native-preview-linux-arm": "npm:7.0.0-dev.20251203.1"
6109+
"@typescript/native-preview-linux-arm64": "npm:7.0.0-dev.20251203.1"
6110+
"@typescript/native-preview-linux-x64": "npm:7.0.0-dev.20251203.1"
6111+
"@typescript/native-preview-win32-arm64": "npm:7.0.0-dev.20251203.1"
6112+
"@typescript/native-preview-win32-x64": "npm:7.0.0-dev.20251203.1"
6113+
dependenciesMeta:
6114+
"@typescript/native-preview-darwin-arm64":
6115+
optional: true
6116+
"@typescript/native-preview-darwin-x64":
6117+
optional: true
6118+
"@typescript/native-preview-linux-arm":
6119+
optional: true
6120+
"@typescript/native-preview-linux-arm64":
6121+
optional: true
6122+
"@typescript/native-preview-linux-x64":
6123+
optional: true
6124+
"@typescript/native-preview-win32-arm64":
6125+
optional: true
6126+
"@typescript/native-preview-win32-x64":
6127+
optional: true
6128+
bin:
6129+
tsgo: bin/tsgo.js
6130+
checksum: 10/dc492141a3f84820786c0174e2f3082355005d258e9fd12eb24d620c90892e358b35dde08d216851edee993b48c69a047f6ba695360bb61ccf998c61f6c09580
6131+
languageName: node
6132+
linkType: hard
6133+
6134+
"@typescript/native-preview@npm:^7.0.0-dev.20251204.1":
6135+
version: 7.0.0-dev.20251204.1
6136+
resolution: "@typescript/native-preview@npm:7.0.0-dev.20251204.1"
6137+
dependencies:
6138+
"@typescript/native-preview-darwin-arm64": "npm:7.0.0-dev.20251204.1"
6139+
"@typescript/native-preview-darwin-x64": "npm:7.0.0-dev.20251204.1"
6140+
"@typescript/native-preview-linux-arm": "npm:7.0.0-dev.20251204.1"
6141+
"@typescript/native-preview-linux-arm64": "npm:7.0.0-dev.20251204.1"
6142+
"@typescript/native-preview-linux-x64": "npm:7.0.0-dev.20251204.1"
6143+
"@typescript/native-preview-win32-arm64": "npm:7.0.0-dev.20251204.1"
6144+
"@typescript/native-preview-win32-x64": "npm:7.0.0-dev.20251204.1"
6145+
dependenciesMeta:
6146+
"@typescript/native-preview-darwin-arm64":
6147+
optional: true
6148+
"@typescript/native-preview-darwin-x64":
6149+
optional: true
6150+
"@typescript/native-preview-linux-arm":
6151+
optional: true
6152+
"@typescript/native-preview-linux-arm64":
6153+
optional: true
6154+
"@typescript/native-preview-linux-x64":
6155+
optional: true
6156+
"@typescript/native-preview-win32-arm64":
6157+
optional: true
6158+
"@typescript/native-preview-win32-x64":
6159+
optional: true
6160+
bin:
6161+
tsgo: bin/tsgo.js
6162+
checksum: 10/060c18167adce55ccc9f854a7b9acd4efaa1b25c44ac4f907e560168a47389d0e3173742e98b2ca9c5767e8e96bcadd906ab1e424cc9ffef8d1f340250e4a7f0
6163+
languageName: node
6164+
linkType: hard
6165+
59996166
"@ungap/structured-clone@npm:^1.0.0, @ungap/structured-clone@npm:^1.2.0":
60006167
version: 1.3.0
60016168
resolution: "@ungap/structured-clone@npm:1.3.0"

0 commit comments

Comments
 (0)