Skip to content
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

Finish applying no-object-literal-type-assertion lint rule #18218

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 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
19 changes: 12 additions & 7 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1916,8 +1916,10 @@ namespace ts {
target.set(id, sourceSymbol);
if (lookupTable && exportNode) {
lookupTable.set(id, {
specifierText: getTextOfNode(exportNode.moduleSpecifier)
} as ExportCollisionTracker);
specifierText: getTextOfNode(exportNode.moduleSpecifier),
// TODO: GH#18217: (exportsWithDuplicate was not present)
exportsWithDuplicate: undefined,
});
}
}
else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) {
Expand Down Expand Up @@ -6391,18 +6393,21 @@ namespace ts {
function createTypePredicateFromTypePredicateNode(node: TypePredicateNode): IdentifierTypePredicate | ThisTypePredicate {
const { parameterName } = node;
if (parameterName.kind === SyntaxKind.Identifier) {
return {
const result: IdentifierTypePredicate = {
kind: TypePredicateKind.Identifier,
parameterName: parameterName ? parameterName.escapedText : undefined,
// TODO: GH#18217 (should unescape parameterName)
parameterName: parameterName ? parameterName.escapedText as string : undefined,
parameterIndex: parameterName ? getTypePredicateParameterIndex((node.parent as SignatureDeclaration).parameters, parameterName) : undefined,
type: getTypeFromTypeNode(node.type)
} as IdentifierTypePredicate;
type: getTypeFromTypeNode(node.type),
};
return result;
}
else {
return {
const result: ThisTypePredicate = {
kind: TypePredicateKind.This,
type: getTypeFromTypeNode(node.type)
};
return result;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@ namespace ts {
*/
export function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): JsonSourceFile {
const textOrDiagnostic = tryReadFile(fileName, readFile);
// tslint:disable-next-line no-object-literal-type-assertion (TODO:GH#18217)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should change the return type for this function instead.

Copy link
Author

@ghost ghost Nov 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To { parseDiagnostics: Diagnostic[] }? That exposes errors in its uses because we seem to assume we get the full source file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with optional members for fileName and extendedSourceFiles.. not sure if we need other things as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that might end up touching many places though..

return isString(textOrDiagnostic) ? parseJsonText(fileName, textOrDiagnostic) : <JsonSourceFile>{ parseDiagnostics: [textOrDiagnostic] };
}

Expand Down
1 change: 1 addition & 0 deletions src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ namespace FourSlash {
"getReferencesAtPosition",
"getDocumentHighlights",
];
// tslint:disable-next-line no-object-literal-type-assertion
const proxy = {} as ts.LanguageService;
for (const k in ls) {
const key = k as keyof typeof ls;
Expand Down
6 changes: 3 additions & 3 deletions src/harness/unittests/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ namespace ts.server {
}
};
session.onMessage(JSON.stringify(setOptionsRequest));
assert.deepEqual(
assert.deepEqual<CompilerOptions>(
session.getProjectService().getCompilerOptionsForInferredProjects(),
<CompilerOptions>{
{
module: ModuleKind.System,
target: ScriptTarget.ES5,
jsx: JsxEmit.React,
Expand Down Expand Up @@ -297,7 +297,7 @@ namespace ts.server {

session.onMessage(JSON.stringify(req));

expect(lastSent).to.deep.equal(<protocol.ConfigureResponse>{
assert.deepEqual<protocol.ConfigureResponse>(lastSent as protocol.ConfigureResponse, {
command: CommandNames.Configure,
type: "response",
success: true,
Expand Down
Loading