mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-23 16:48:41 -05:00
Created a branded type for identifier-escaped strings (#16915)
* Created a branded type for escaped strings Then flowed it throughout the compiler, finding and fixing a handful of bugs relating to underscore-prefixed identifiers in the process. Includes a test for two cases noticed - diagnostics from conflicting symbols from export *'s, and enum with underscore prefixed member emit. * Correctly double underscores WRT mapped types * Add fourslash tests for other fixed issues * use function call over cast * Update forEachEntry type accuracy * Just use escaped names for ActiveLabel * Remove casts from getPropertyNameForPropertyNameNode * This pattern has occurred a few times, could use a helper function. * Remove duplicated helper * Remove unneeded check, use helper * Identifiers list is no longer escaped strings * Extract repeated string-getting code into helper * Rename type and associated functions * Make getName() return UnderscoreEscapedString, add getUnescapedName() * Add list of internal symbol names to escaped string type to cut back on casting * Remove outdated comments * Reassign interned values to nodes, just in case * Swap to string enum * Add deprecated aliases to escapeIdentifier and unescapeIdentifier * Add temp var * Remove unsafe casts * Rename escaped string type as per @sandersn's suggestion, fix string enum usages * Reorganize double underscore tests * Remove jfreeman from TODO * Remove unneeded parenthesis
This commit is contained in:
@@ -405,7 +405,7 @@ namespace ts {
|
||||
let commonSourceDirectory: string;
|
||||
let diagnosticsProducingTypeChecker: TypeChecker;
|
||||
let noDiagnosticsTypeChecker: TypeChecker;
|
||||
let classifiableNames: Map<string>;
|
||||
let classifiableNames: UnderscoreEscapedMap<__String>;
|
||||
let modifiedFilePaths: Path[] | undefined;
|
||||
|
||||
const cachedSemanticDiagnosticsForFile: DiagnosticCache = {};
|
||||
@@ -580,7 +580,7 @@ namespace ts {
|
||||
if (!classifiableNames) {
|
||||
// Initialize a checker so that all our files are bound.
|
||||
getTypeChecker();
|
||||
classifiableNames = createMap<string>();
|
||||
classifiableNames = createUnderscoreEscapedMap<__String>();
|
||||
|
||||
for (const sourceFile of files) {
|
||||
copyEntries(sourceFile.classifiableNames, classifiableNames);
|
||||
|
||||
Reference in New Issue
Block a user