mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-13 22:53:33 -05:00
In fourslash.ts, remove unused exports and use '{}' instead of 'any' (#21377)
This commit is contained in:
@@ -23,7 +23,7 @@ namespace FourSlash {
|
||||
ts.disableIncrementalParsing = false;
|
||||
|
||||
// Represents a parsed source file with metadata
|
||||
export interface FourSlashFile {
|
||||
interface FourSlashFile {
|
||||
// The contents of the file (with markers, etc stripped out)
|
||||
content: string;
|
||||
fileName: string;
|
||||
@@ -34,7 +34,7 @@ namespace FourSlash {
|
||||
}
|
||||
|
||||
// Represents a set of parsed source files and options
|
||||
export interface FourSlashData {
|
||||
interface FourSlashData {
|
||||
// Global options (name/value pairs)
|
||||
globalOptions: Harness.TestCaseParser.CompilerSettings;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace FourSlash {
|
||||
export interface Marker {
|
||||
fileName: string;
|
||||
position: number;
|
||||
data?: any;
|
||||
data?: {};
|
||||
}
|
||||
|
||||
export interface Range {
|
||||
@@ -89,21 +89,6 @@ namespace FourSlash {
|
||||
end: number;
|
||||
}
|
||||
|
||||
export import IndentStyle = ts.IndentStyle;
|
||||
|
||||
const entityMap = ts.createMapFromTemplate({
|
||||
"&": "&",
|
||||
"\"": """,
|
||||
"'": "'",
|
||||
"/": "/",
|
||||
"<": "<",
|
||||
">": ">"
|
||||
});
|
||||
|
||||
export function escapeXmlAttributeValue(s: string) {
|
||||
return s.replace(/[&<>"'\/]/g, ch => entityMap.get(ch));
|
||||
}
|
||||
|
||||
// Name of testcase metadata including ts.CompilerOptions properties that will be used by globalOptions
|
||||
// To add additional option, add property into the testOptMetadataNames, refer the property in either globalMetadataNames or fileMetadataNames
|
||||
// Add cases into convertGlobalOptionsToCompilationsSettings function for the compiler to acknowledge such option from meta data
|
||||
@@ -1079,7 +1064,7 @@ namespace FourSlash {
|
||||
for (const reference of expectedReferences) {
|
||||
const { fileName, start, end } = reference;
|
||||
if (reference.marker && reference.marker.data) {
|
||||
const { isWriteAccess, isDefinition } = reference.marker.data;
|
||||
const { isWriteAccess, isDefinition } = reference.marker.data as { isWriteAccess?: boolean, isDefinition?: boolean };
|
||||
this.verifyReferencesWorker(actualReferences, fileName, start, end, isWriteAccess, isDefinition);
|
||||
}
|
||||
else {
|
||||
@@ -1108,7 +1093,16 @@ namespace FourSlash {
|
||||
}
|
||||
const fullExpected = ts.map<FourSlashInterface.ReferenceGroup, ReferenceGroupJson>(parts, ({ definition, ranges }) => ({
|
||||
definition: typeof definition === "string" ? definition : { ...definition, range: textSpanFromRange(definition.range) },
|
||||
references: ranges.map(rangeToReferenceEntry),
|
||||
references: ranges.map<ts.ReferenceEntry>(r => {
|
||||
const { isWriteAccess = false, isDefinition = false, isInString } = (r.marker && r.marker.data || {}) as { isWriteAccess?: boolean, isDefinition?: boolean, isInString?: true };
|
||||
return {
|
||||
isWriteAccess,
|
||||
isDefinition,
|
||||
fileName: r.fileName,
|
||||
textSpan: textSpanFromRange(r),
|
||||
...(isInString ? { isInString: true } : undefined),
|
||||
};
|
||||
}),
|
||||
}));
|
||||
|
||||
for (const startRange of toArray(startRanges)) {
|
||||
@@ -1122,15 +1116,6 @@ namespace FourSlash {
|
||||
});
|
||||
this.assertObjectsEqual(fullActual, fullExpected);
|
||||
}
|
||||
|
||||
function rangeToReferenceEntry(r: Range): ts.ReferenceEntry {
|
||||
const { isWriteAccess, isDefinition, isInString } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false, isInString: undefined };
|
||||
const result: ts.ReferenceEntry = { fileName: r.fileName, textSpan: textSpanFromRange(r), isWriteAccess: !!isWriteAccess, isDefinition: !!isDefinition };
|
||||
if (isInString !== undefined) {
|
||||
result.isInString = isInString;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public verifyNoReferences(markerNameOrRange?: string | Range) {
|
||||
|
||||
Reference in New Issue
Block a user