Skip to content

Commit 5763dbc

Browse files
committed
docs(docs-infra): Use type aquisition in the tutorial editor
Automatic Type Acquisition (ata), loads all the necessary types from a given file content.
1 parent e7ff105 commit 5763dbc

File tree

6 files changed

+50
-11
lines changed

6 files changed

+50
-11
lines changed

.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
adev/shared-docs/pipeline/api-gen/package.json=939673974
77
integration/package.json=-239561259
88
modules/package.json=364168920
9-
package.json=-1928784858
9+
package.json=903175873
1010
packages/animations/package.json=-678724831
1111
packages/benchpress/package.json=-1908328724
1212
packages/common/package.json=1729763064
@@ -22,7 +22,7 @@ packages/platform-browser/package.json=-1163479450
2222
packages/router/package.json=860819913
2323
packages/upgrade/package.json=16347051
2424
packages/zone.js/package.json=-1005735564
25-
pnpm-lock.yaml=-103202685
25+
pnpm-lock.yaml=-1818670978
2626
pnpm-workspace.yaml=-375658197
2727
tools/bazel/rules_angular_store/package.json=-239561259
28-
yarn.lock=-774434861
28+
yarn.lock=1951867410

adev/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ APPLICATION_DEPS = [
7070
"@npm//xhr2",
7171
"@npm//typescript",
7272
"@npm//@typescript/vfs",
73+
"@npm//@typescript/ata",
7374
"@npm//@codemirror/state",
7475
"@npm//@codemirror/view",
7576
"@npm//@codemirror/language",

adev/src/app/editor/typings-loader.service.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {Injectable, signal} from '@angular/core';
1010
import {toObservable} from '@angular/core/rxjs-interop';
1111
import {WebContainer} from '@webcontainer/api';
1212
import {Typing} from './code-editor/workers/interfaces/define-types-request';
13+
import {setupTypeAcquisition} from '@typescript/ata';
14+
import ts from 'typescript';
1315

1416
/**
1517
* This service is responsible for retrieving the types definitions for the
@@ -41,15 +43,37 @@ export class TypingsLoader {
4143

4244
const typesDefinitions: Typing[] = [];
4345

46+
const ata = setupTypeAcquisition({
47+
projectName: 'My ATA Project',
48+
typescript: ts,
49+
logger: console,
50+
delegate: {
51+
receivedFile: (content: string, path: string) => {
52+
if (path.endsWith('.d.ts')) {
53+
typesDefinitions.push({path, content});
54+
}
55+
},
56+
started: () => {},
57+
progress: () => {},
58+
finished: () => {},
59+
},
60+
});
61+
4462
try {
4563
const filesToRead = await this.getFilesToRead();
4664

4765
if (filesToRead && filesToRead.length > 0) {
4866
await Promise.all(
4967
filesToRead.map((path) =>
50-
webContainer.fs.readFile(path, 'utf-8').then((content) => {
51-
typesDefinitions.push({path, content});
52-
}),
68+
webContainer.fs
69+
.readFile(path, 'utf-8')
70+
.then(async (content) => {
71+
await ata(content);
72+
return content;
73+
})
74+
.then((content) => {
75+
typesDefinitions.push({path, content});
76+
}),
5377
),
5478
);
5579

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
"@babel/generator": "7.27.5",
6666
"@bazel/concatjs": "5.8.1",
6767
"@bazel/esbuild": "5.8.1",
68-
"esbuild": "0.25.5",
6968
"@bazel/jasmine": "5.8.1",
7069
"@bazel/protractor": "5.8.1",
7170
"@bazel/rollup": "5.8.1",
@@ -116,6 +115,7 @@
116115
"dagre-d3-es": "^7.0.11",
117116
"diff": "^8.0.0",
118117
"domino": "https://github.com/angular/domino.git#93e720f143d0296dd2726ffbcf4fc12283363a7b",
118+
"esbuild": "0.25.5",
119119
"hammerjs": "~2.0.8",
120120
"http-server": "^14.0.0",
121121
"jasmine": "~5.8.0",
@@ -196,6 +196,7 @@
196196
"@types/jsdom": "^21.1.5",
197197
"@types/live-server": "^1.2.3",
198198
"@types/tmp": "^0.2.6",
199+
"@typescript/ata": "^0.9.8",
199200
"@typescript/vfs": "^1.5.0",
200201
"@webcontainer/api": "^1.3.0-internal.2",
201202
"@yarnpkg/lockfile": "^1.1.0",

pnpm-lock.yaml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

yarn.lock

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@
320320

321321
"@angular/build-tooling@https://github.com/angular/dev-infra-private-build-tooling-builds.git#5db176c0f3211663830fd3ff4064c1dff0eaccb4":
322322
version "0.0.0-d44be7e28087c3499d70dda9859d51c1cd3fe1bf"
323-
uid "5db176c0f3211663830fd3ff4064c1dff0eaccb4"
324323
resolved "https://github.com/angular/dev-infra-private-build-tooling-builds.git#5db176c0f3211663830fd3ff4064c1dff0eaccb4"
325324
dependencies:
326325
"@angular/benchpress" "0.3.0"
@@ -470,7 +469,6 @@
470469

471470
"@angular/ng-dev@https://github.com/angular/dev-infra-private-ng-dev-builds.git#8fe809d31ea3536087ca56cf7ff9ddd544dba658":
472471
version "0.0.0-dfe138678e4edb4789fbe40ae7792c046de3b4bd"
473-
uid "8fe809d31ea3536087ca56cf7ff9ddd544dba658"
474472
resolved "https://github.com/angular/dev-infra-private-ng-dev-builds.git#8fe809d31ea3536087ca56cf7ff9ddd544dba658"
475473
dependencies:
476474
"@google-cloud/spanner" "8.0.0"
@@ -4839,6 +4837,11 @@
48394837
dependencies:
48404838
"@types/node" "*"
48414839

4840+
"@typescript/ata@^0.9.8":
4841+
version "0.9.8"
4842+
resolved "https://registry.yarnpkg.com/@typescript/ata/-/ata-0.9.8.tgz#97fe634905ad6140197bc812a696d3ebe315d519"
4843+
integrity sha512-+M815CeDRJS5H5ciWfhFCKp25nNfF+LFWawWAaBhNlquFb2wS5IIMDI+2bKWN3GuU6mpj+FzySsOD29M4nG8Xg==
4844+
48424845
"@typescript/vfs@^1.5.0":
48434846
version "1.6.1"
48444847
resolved "https://registry.yarnpkg.com/@typescript/vfs/-/vfs-1.6.1.tgz#fe7087d5a43715754f7ea9bf6e0b905176c9eebd"
@@ -8038,8 +8041,7 @@ domhandler@^5.0.2, domhandler@^5.0.3:
80388041
domelementtype "^2.3.0"
80398042

80408043
"domino@https://github.com/angular/domino.git#93e720f143d0296dd2726ffbcf4fc12283363a7b":
8041-
version "2.1.6+git"
8042-
uid "93e720f143d0296dd2726ffbcf4fc12283363a7b"
8044+
version "2.1.6"
80438045
resolved "https://github.com/angular/domino.git#93e720f143d0296dd2726ffbcf4fc12283363a7b"
80448046

80458047
dompurify@^3.2.5:

0 commit comments

Comments
 (0)