mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
Make a few changes to allow all code to be loaded as one project
This commit is contained in:
parent
d83a5e1281
commit
df89c7457d
@ -14,6 +14,13 @@ namespace ts {
|
||||
NoOriginalNode = 1 << 3,
|
||||
}
|
||||
|
||||
const nodeFactoryPatchers: ((factory: NodeFactory) => void)[] = [];
|
||||
|
||||
/* @internal */
|
||||
export function addNodeFactoryPatcher(fn: (factory: NodeFactory) => void) {
|
||||
nodeFactoryPatchers.push(fn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a `NodeFactory` that can be used to create and update a syntax tree.
|
||||
* @param flags Flags that control factory behavior.
|
||||
@ -161,11 +168,11 @@ namespace ts {
|
||||
createObjectLiteralExpression,
|
||||
updateObjectLiteralExpression,
|
||||
createPropertyAccessExpression: flags & NodeFactoryFlags.NoIndentationOnFreshPropertyAccess ?
|
||||
(expression, name) => setEmitFlags(createPropertyAccessExpression(expression, name), EmitFlags.NoIndentation) :
|
||||
(expression: Expression, name: string | MemberName) => setEmitFlags(createPropertyAccessExpression(expression, name), EmitFlags.NoIndentation) :
|
||||
createPropertyAccessExpression,
|
||||
updatePropertyAccessExpression,
|
||||
createPropertyAccessChain: flags & NodeFactoryFlags.NoIndentationOnFreshPropertyAccess ?
|
||||
(expression, questionDotToken, name) => setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), EmitFlags.NoIndentation) :
|
||||
(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | MemberName) => setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), EmitFlags.NoIndentation) :
|
||||
createPropertyAccessChain,
|
||||
updatePropertyAccessChain,
|
||||
createElementAccessExpression,
|
||||
@ -534,7 +541,9 @@ namespace ts {
|
||||
liftToBlock,
|
||||
mergeLexicalEnvironment,
|
||||
updateModifiers,
|
||||
};
|
||||
} as any;
|
||||
|
||||
forEach(nodeFactoryPatchers, fn => fn(factory));
|
||||
|
||||
return factory;
|
||||
|
||||
|
||||
@ -59,16 +59,8 @@ namespace ts {
|
||||
|
||||
// Patch `createNodeFactory` because it creates the factories that are provided to transformers
|
||||
// in the public API.
|
||||
|
||||
const prevCreateNodeFactory = createNodeFactory;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier
|
||||
ts.createNodeFactory = (flags, baseFactory) => {
|
||||
const factory = prevCreateNodeFactory(flags, baseFactory);
|
||||
patchNodeFactory(factory);
|
||||
return factory;
|
||||
};
|
||||
addNodeFactoryPatcher(patchNodeFactory);
|
||||
|
||||
// Patch `ts.factory` because its public
|
||||
patchNodeFactory(factory);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,16 +80,8 @@ namespace ts {
|
||||
|
||||
// Patch `createNodeFactory` because it creates the factories that are provided to transformers
|
||||
// in the public API.
|
||||
|
||||
const prevCreateNodeFactory = createNodeFactory;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier
|
||||
ts.createNodeFactory = (flags, baseFactory) => {
|
||||
const factory = prevCreateNodeFactory(flags, baseFactory);
|
||||
patchNodeFactory(factory);
|
||||
return factory;
|
||||
};
|
||||
addNodeFactoryPatcher(patchNodeFactory);
|
||||
|
||||
// Patch `ts.factory` because its public
|
||||
patchNodeFactory(factory);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,16 +65,8 @@ namespace ts {
|
||||
|
||||
// Patch `createNodeFactory` because it creates the factories that are provided to transformers
|
||||
// in the public API.
|
||||
|
||||
const prevCreateNodeFactory = createNodeFactory;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier
|
||||
ts.createNodeFactory = (flags, baseFactory) => {
|
||||
const factory = prevCreateNodeFactory(flags, baseFactory);
|
||||
patchNodeFactory(factory);
|
||||
return factory;
|
||||
};
|
||||
addNodeFactoryPatcher(patchNodeFactory);
|
||||
|
||||
// Patch `ts.factory` because its public
|
||||
patchNodeFactory(factory);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1397,15 +1397,7 @@ namespace ts {
|
||||
|
||||
// Patch `createNodeFactory` because it creates the factories that are provided to transformers
|
||||
// in the public API.
|
||||
|
||||
const prevCreateNodeFactory = createNodeFactory;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier
|
||||
ts.createNodeFactory = (flags, baseFactory) => {
|
||||
const factory = prevCreateNodeFactory(flags, baseFactory);
|
||||
patchNodeFactory(factory);
|
||||
return factory;
|
||||
};
|
||||
addNodeFactoryPatcher(patchNodeFactory);
|
||||
|
||||
// Patch `ts.factory` because its public
|
||||
patchNodeFactory(factory);
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
/*@internal*/
|
||||
|
||||
/// <reference lib="webworker" />
|
||||
|
||||
namespace ts.server {
|
||||
declare const addEventListener: any;
|
||||
declare const postMessage: any;
|
||||
declare const close: any;
|
||||
declare const location: any;
|
||||
declare const XMLHttpRequest: any;
|
||||
declare const self: any;
|
||||
|
||||
const nullLogger: Logger = {
|
||||
close: noop,
|
||||
hasLevel: returnFalse,
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
/*@internal*/
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="webworker.importscripts" />
|
||||
|
||||
namespace ts.server {
|
||||
declare const fetch: any;
|
||||
declare const importScripts: any;
|
||||
|
||||
export interface HostWithWriteMessage {
|
||||
writeMessage(s: any): void;
|
||||
}
|
||||
@ -112,8 +113,6 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
export declare const dynamicImport: ((id: string) => Promise<any>) | undefined;
|
||||
|
||||
// Attempt to load `dynamicImport`
|
||||
if (typeof importScripts === "function") {
|
||||
try {
|
||||
@ -132,9 +131,10 @@ namespace ts.server {
|
||||
const getWebPath = (path: string) => startsWith(path, directorySeparator) ? path.replace(directorySeparator, getExecutingDirectoryPath()) : undefined;
|
||||
|
||||
const dynamicImport = async (id: string): Promise<any> => {
|
||||
const serverDynamicImport: ((id: string) => Promise<any>) | undefined = (server as any).dynamicImport;
|
||||
// Use syntactic dynamic import first, if available
|
||||
if (server.dynamicImport) {
|
||||
return server.dynamicImport(id);
|
||||
if (serverDynamicImport) {
|
||||
return serverDynamicImport(id);
|
||||
}
|
||||
|
||||
throw new Error("Dynamic import not implemented");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user