Skip to content

Fix getTypeAtLocation for as const to not issue a diagnostic #36741

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
Merged
Changes from 1 commit
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
Prev Previous commit
Merge branch 'master' into fix-ls-gettypeatlocation-for-as-const
  • Loading branch information
weswigham committed Feb 12, 2020
commit a85b27c0c4addcf98acfe4bde1afe08f3e13138e
13 changes: 12 additions & 1 deletion src/testRunner/unittests/programApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ namespace ts {
});
});


describe("unittests:: programApi:: Program.getDiagnosticsProducingTypeChecker / Program.getSemanticDiagnostics", () => {
it("does not produce errors on `as const` it would not normally produce on the command line", () => {
const main = new documents.TextDocument("/main.ts", "0 as const");
Expand All @@ -192,5 +191,17 @@ namespace ts {
const diag = program.getSemanticDiagnostics();
assert.isEmpty(diag);
});
it("getSymbolAtLocation does not cause additional error to be added on module resolution failure", () => {
const main = new documents.TextDocument("/main.ts", "import \"./module\";");
const mod = new documents.TextDocument("/module.d.ts", "declare const foo: any;");

const fs = vfs.createFromFileSystem(Harness.IO, /*ignoreCase*/ false, { documents: [main, mod], cwd: "/" });
const program = createProgram(["/main.ts"], {}, new fakes.CompilerHost(fs, { newLine: NewLineKind.LineFeed }));

const sourceFile = program.getSourceFile("main.ts")!;
const typeChecker = program.getDiagnosticsProducingTypeChecker();
typeChecker.getSymbolAtLocation((sourceFile.statements[0] as ImportDeclaration).moduleSpecifier);
assert.isEmpty(program.getSemanticDiagnostics());
});
});
}
You are viewing a condensed version of this merge commit. You can view the full changes here.
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy