-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Web: provide a workbench.web.api.d.ts
for an embedder to develop against
#125643
Comments
Loader piece is done will defer the .d.ts to a later date |
workbench.web.api.d.ts
for an embedder to develop against
Following up on discussion on other internal issues, I suggest not automatically generating the .d.ts, and instead have the web api .d.ts checked into VS Code and with manually duplicated types. The reason is that we have dependency on code and typings for embedders, but it is very easy for team members to not realize that code they're working is exposed in this API and depended upon by the embedder. This may result in breakages, especially if it's something as easy and innocent as an automated refactor for a property rename. Causing a compilation error unless the web .d.ts is manually and explicitly updated would reduce the likelihood of accidental breakages. |
I think there are 2 camps: |
My 2c. I love that |
+💯. Creating those types manually is IMO the only way to guarantee awareness of changes in API and to "design" the API explicitly. That's also the different between |
I am fine handpicking the API for embedder but I wonder how we could validate the correctness of the API then: we need to ensure we implement the API also in the workbench to get type failures early. In other words, we cannot just hand craft a d.ts file and not validate it with our actual code. I think |
Yeah, we explicitly implement the API in
|
@joaomoreno pointed out this tool which maybe could help: https://api-extractor.com/ Naive first run and error: microsoft/rushstack#3738 |
@bpasero i'm interested in this, any progress? |
I tried using api-extractor by using the new typescript 5.6.0 noCheck option to compile a separate folder of Then I tried using https://github.com/timocov/dts-bundle-generator and it worked a charm, I created: declarations/package.json: {
"name": "declaration",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"overrides": {},
"dependencies": {
"dts-bundle-generator": "^9.5.1",
"typescript": "5.6.0-dev.20240723"
},
"resolutions": {
"**/typescript": "5.6.0-dev.20240723"
},
"scripts": {
"build": "dts-bundle-generator -o workbench.d.ts --project tsconfig.json ../src/vs/workbench/browser/web.api.ts"
}
} declarations/tsconfig.json: {
"compilerOptions": {
"moduleResolution": "node",
"baseUrl": "../src",
"paths": {
"vs/*": ["../src/vs/*"]
},
"target": "es2022",
"skipLibCheck": true,
"noCheck": true,
"lib": ["ES2022", "DOM", "DOM.Iterable", "WebWorker.ImportScripts"]
},
"include": [
"../src/vs/**/*.ts",
"vscode-dts/vscode.proposed.*.d.ts",
"vscode-dts/vscode.d.ts"
]
} and then run |
Cool, can you attach the resulting file here? Curious how it compares to the one we manually craft. |
Btw when I try I get an error:
Update: nevermind, I did not have TS 5.6.x installed. The resulting file is: |
We provide an API surface for an embedder of our web UI:
vscode/src/vs/workbench/workbench.web.api.ts
Line 238 in 7a83e5a
We also require some specific setup to load our web UI pieces as indicated by our
yarn web
implementation:vscode/src/vs/code/browser/workbench/workbench.html
Line 42 in c87c95a
We should:
workbench.web.api.d.ts
(similar tomonaco.d.ts
) for theworkbench.web.api
for an embedder to develop againstamdconfig.js
?) that an embedder can just point toThe text was updated successfully, but these errors were encountered: