Run our build scripts directly as typescript (#277567)

* Run our build scripts directly as typescript #277567

Follow up on #276864
For #277526

* Remove a few more ts-node references

* Fix linux and script reference

* Remove `_build-script` ref

* Fix script missing closing quote

* use type only import

* Fix export

* Make sure to run copy-policy-dto

* Make sure we run the copy-policy-dto script

* Enable `verbatimModuleSyntax`

* Pipelines fixes

* Try adding explicit ext to path

* Fix bad edit

* Revert extra `--`

---------

Co-authored-by: João Moreno <joaomoreno@users.noreply.github.com>
This commit is contained in:
Matt Bierner
2025-11-21 05:56:00 -08:00
committed by GitHub
parent b2426c5705
commit 2648263d3e
242 changed files with 977 additions and 16037 deletions

View File

@@ -6,11 +6,11 @@
import fs from 'fs';
import path from 'path';
import crypto from 'crypto';
import * as utils from './utils';
import * as utils from './utils.ts';
import colors from 'ansi-colors';
import ts from 'typescript';
import Vinyl from 'vinyl';
import { RawSourceMap, SourceMapConsumer, SourceMapGenerator } from 'source-map';
import { type RawSourceMap, SourceMapConsumer, SourceMapGenerator } from 'source-map';
export interface IConfiguration {
logFn: (topic: string, message: string) => void;
@@ -21,11 +21,11 @@ export interface CancellationToken {
isCancellationRequested(): boolean;
}
export namespace CancellationToken {
export const None: CancellationToken = {
export const CancellationToken = new class {
None: CancellationToken = {
isCancellationRequested() { return false; }
};
}
};
export interface ITypeScriptBuilder {
build(out: (file: Vinyl) => void, onError: (err: ts.Diagnostic) => void, token?: CancellationToken): Promise<any>;
@@ -167,7 +167,7 @@ export function createTypeScriptBuilder(config: IConfiguration, projectFile: str
const dirname = path.dirname(vinyl.relative);
const tsname = (dirname === '.' ? '' : dirname + '/') + basename + '.ts';
let sourceMap = <RawSourceMap>JSON.parse(sourcemapFile.text);
let sourceMap = JSON.parse(sourcemapFile.text) as RawSourceMap;
sourceMap.sources[0] = tsname.replace(/\\/g, '/');
// check for an "input source" map and combine them
@@ -227,7 +227,7 @@ export function createTypeScriptBuilder(config: IConfiguration, projectFile: str
}
[tsSMC, inputSMC].forEach((consumer) => {
(<SourceMapConsumer & { sources: string[] }>consumer).sources.forEach((sourceFile: string) => {
(consumer as SourceMapConsumer & { sources: string[] }).sources.forEach((sourceFile: string) => {
(smg as SourceMapGeneratorWithSources)._sources.add(sourceFile);
const sourceContent = consumer.sourceContentFor(sourceFile);
if (sourceContent !== null) {
@@ -529,19 +529,25 @@ class LanguageServiceHost implements ts.LanguageServiceHost {
private readonly _snapshots: { [path: string]: ScriptSnapshot };
private readonly _filesInProject: Set<string>;
private readonly _filesAdded: Set<string>;
private readonly _dependencies: utils.graph.Graph<string>;
private readonly _dependencies: InstanceType<typeof utils.graph.Graph<string>>;
private readonly _dependenciesRecomputeList: string[];
private readonly _fileNameToDeclaredModule: { [path: string]: string[] };
private _projectVersion: number;
private readonly _cmdLine: ts.ParsedCommandLine;
private readonly _projectPath: string;
private readonly _log: (topic: string, message: string) => void;
constructor(
private readonly _cmdLine: ts.ParsedCommandLine,
private readonly _projectPath: string,
private readonly _log: (topic: string, message: string) => void
cmdLine: ts.ParsedCommandLine,
projectPath: string,
log: (topic: string, message: string) => void
) {
this._cmdLine = cmdLine;
this._projectPath = projectPath;
this._log = log;
this._snapshots = Object.create(null);
this._filesInProject = new Set(_cmdLine.fileNames);
this._filesInProject = new Set(this._cmdLine.fileNames);
this._filesAdded = new Set();
this._dependencies = new utils.graph.Graph<string>();
this._dependenciesRecomputeList = [];
@@ -665,7 +671,7 @@ class LanguageServiceHost implements ts.LanguageServiceHost {
filename = normalize(filename);
const node = this._dependencies.lookup(filename);
if (node) {
node.incoming.forEach(entry => target.push(entry.data));
node.incoming.forEach((entry: any) => target.push(entry.data));
}
}