Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions 10 Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,12 @@ const localize = async () => {
}
};

const buildShims = () => buildProject("src/shims");
const cleanShims = () => cleanProject("src/shims");
cleanTasks.push(cleanShims);

const buildDebugTools = () => buildProject("src/debug");
const cleanDebugTools = () => cleanProject("src/debug");
cleanTasks.push(cleanDebugTools);

const buildShimsAndTools = parallel(buildShims, buildDebugTools);

// Pre-build steps when targeting the LKG compiler
const lkgPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnostics, buildShimsAndTools));
const lkgPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnostics, buildDebugTools));

const buildTsc = () => buildProject("src/tsc");
task("tsc", series(lkgPreBuild, buildTsc));
Expand All @@ -119,7 +113,7 @@ task("watch-tsc", series(lkgPreBuild, parallel(watchLib, watchDiagnostics, watch
task("watch-tsc").description = "Watch for changes and rebuild the command-line compiler only.";

// Pre-build steps when targeting the built/local compiler.
const localPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnostics, buildShimsAndTools, buildTsc));
const localPreBuild = parallel(generateLibs, series(buildScripts, generateDiagnostics, buildDebugTools, buildTsc));

// Pre-build steps to use based on supplied options.
const preBuild = cmdLineOptions.lkg ? lkgPreBuild : localPreBuild;
Expand Down
39 changes: 14 additions & 25 deletions 39 src/compiler/corePublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,45 +124,34 @@ namespace ts {
/**
* Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
*/
export function tryGetNativeMap(): MapConstructor | undefined {
export function tryGetNativeMap(): MapConstructor {
// Internet Explorer's Map doesn't support iteration, so don't use it.
const gMap = globals?.Map;
// eslint-disable-next-line no-in-operator
return typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
const constructor = typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
if (!constructor) {
throw new Error("No compatible Map implementation found.");
}
return constructor;
}

/**
* Returns the native Set implementation if it is available and compatible (i.e. supports iteration).
*/
export function tryGetNativeSet(): SetConstructor | undefined {
export function tryGetNativeSet(): SetConstructor {
// Internet Explorer's Set doesn't support iteration, so don't use it.
const gSet = globals?.Set;
// eslint-disable-next-line no-in-operator
return typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
const constructor = typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
if (!constructor) {
throw new Error("No compatible Set implementation found.");
}
return constructor;
}
}

/* @internal */
export const Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
export const Map = NativeCollections.tryGetNativeMap();
/* @internal */
export const Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");

/* @internal */
type GetIteratorCallback = <I extends readonly any[] | ReadonlySet<any> | ReadonlyESMap<any, any> | undefined>(iterable: I) => Iterator<
I extends ReadonlyESMap<infer K, infer V> ? [K, V] :
I extends ReadonlySet<infer T> ? T :
I extends readonly (infer T)[] ? T :
I extends undefined ? undefined :
never>;

/* @internal */
function getCollectionImplementation<
K1 extends MatchingKeys<typeof NativeCollections, () => any>,
K2 extends MatchingKeys<typeof ShimCollections, (getIterator?: GetIteratorCallback) => ReturnType<(typeof NativeCollections)[K1]>>
>(name: string, nativeFactory: K1, shimFactory: K2): NonNullable<ReturnType<(typeof NativeCollections)[K1]>> {
// NOTE: ts.ShimCollections will be defined for typescriptServices.js but not for tsc.js, so we must test for it.
const constructor = NativeCollections[nativeFactory]() ?? ShimCollections?.[shimFactory](getIterator);
if (constructor) return constructor as NonNullable<ReturnType<(typeof NativeCollections)[K1]>>;
throw new Error(`TypeScript requires an environment that provides a compatible native ${name} implementation.`);
}
export const Set = NativeCollections.tryGetNativeSet();
}
1 change: 0 additions & 1 deletion 1 src/compiler/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
},

"references": [
{ "path": "../shims" }
],

"files": [
Expand Down
1 change: 0 additions & 1 deletion 1 src/compiler/tsconfig.release.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
"preserveConstEnums": false
},
"references": [
{ "path": "../shims" }
]
}
1 change: 0 additions & 1 deletion 1 src/services/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"outFile": "../../built/local/services.js"
},
"references": [
{ "path": "../shims" },
{ "path": "../compiler" },
{ "path": "../jsTyping" }
],
Expand Down
267 changes: 0 additions & 267 deletions 267 src/shims/collectionShims.ts

This file was deleted.

9 changes: 0 additions & 9 deletions 9 src/shims/tsconfig.json

This file was deleted.

Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.