Skip to content

In fourslash.ts, remove unused exports and use '{}' instead of 'any' #21377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 commit merged into from
Jan 24, 2018
Merged
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
43 changes: 14 additions & 29 deletions src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -59,7 +59,7 @@ namespace FourSlash {
export interface Marker {
fileName: string;
position: number;
data?: any;
data?: {};
}

export interface Range {
Expand Down Expand Up @@ -89,21 +89,6 @@ namespace FourSlash {
end: number;
}

export import IndentStyle = ts.IndentStyle;

const entityMap = ts.createMapFromTemplate({
"&": "&",
"\"": """,
"'": "'",
"/": "/",
"<": "&lt;",
">": "&gt;"
});

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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)) {
Expand All @@ -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) {
Expand Down