mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-25 12:40:05 -05:00
Add a helper function getOrUpdateProperty to prevent unprotected access to Maps.
This commit is contained in:
@@ -20,6 +20,7 @@ declare module "gulp-typescript" {
|
||||
}
|
||||
import * as insert from "gulp-insert";
|
||||
import * as sourcemaps from "gulp-sourcemaps";
|
||||
import Q = require("q");
|
||||
declare global {
|
||||
// This is silly. We include Q because orchestrator (a part of gulp) depends on it, but its not included.
|
||||
// `del` further depends on `Promise` (and is also not included), so we just, patch the global scope's Promise to Q's
|
||||
|
||||
@@ -319,7 +319,11 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getProperty<T>(map: Map<T>, key: string): T {
|
||||
return hasOwnProperty.call(map, key) ? map[key] : undefined;
|
||||
return hasProperty(map, key) ? map[key] : undefined;
|
||||
}
|
||||
|
||||
export function getOrUpdateProperty<T>(map: Map<T>, key: string, makeValue: () => T): T {
|
||||
return hasProperty(map, key) ? map[key] : map[key] = makeValue();
|
||||
}
|
||||
|
||||
export function isEmpty<T>(map: Map<T>) {
|
||||
@@ -928,7 +932,7 @@ namespace ts {
|
||||
* [^./] # matches everything up to the first . character (excluding directory seperators)
|
||||
* (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension
|
||||
*/
|
||||
const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*";
|
||||
const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*";
|
||||
const singleAsteriskRegexFragmentOther = "[^/]*";
|
||||
|
||||
export function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude") {
|
||||
|
||||
@@ -6841,7 +6841,7 @@ const _super = (function (geti, seti) {
|
||||
// export { x, y }
|
||||
for (const specifier of (<ExportDeclaration>node).exportClause.elements) {
|
||||
const name = (specifier.propertyName || specifier.name).text;
|
||||
(exportSpecifiers[name] || (exportSpecifiers[name] = [])).push(specifier);
|
||||
getOrUpdateProperty(exportSpecifiers, name, () => []).push(specifier);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
9
tests/baselines/reference/exportToString.js
Normal file
9
tests/baselines/reference/exportToString.js
Normal file
@@ -0,0 +1,9 @@
|
||||
//// [exportToString.ts]
|
||||
const toString = 0;
|
||||
export { toString };
|
||||
|
||||
|
||||
//// [exportToString.js]
|
||||
"use strict";
|
||||
var toString = 0;
|
||||
exports.toString = toString;
|
||||
7
tests/baselines/reference/exportToString.symbols
Normal file
7
tests/baselines/reference/exportToString.symbols
Normal file
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/compiler/exportToString.ts ===
|
||||
const toString = 0;
|
||||
>toString : Symbol(toString, Decl(exportToString.ts, 0, 5))
|
||||
|
||||
export { toString };
|
||||
>toString : Symbol(toString, Decl(exportToString.ts, 1, 8))
|
||||
|
||||
8
tests/baselines/reference/exportToString.types
Normal file
8
tests/baselines/reference/exportToString.types
Normal file
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/exportToString.ts ===
|
||||
const toString = 0;
|
||||
>toString : number
|
||||
>0 : number
|
||||
|
||||
export { toString };
|
||||
>toString : number
|
||||
|
||||
2
tests/cases/compiler/exportToString.ts
Normal file
2
tests/cases/compiler/exportToString.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
const toString = 0;
|
||||
export { toString };
|
||||
Reference in New Issue
Block a user