Skip to content

Don't set NodeFlags.JavaScriptFile on JSON, avoid asking for JSDoc outside of JS #52641

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,6 @@ import {
isInitializedProperty,
isInJSDoc,
isInJSFile,
isInJsonFile,
isInterfaceDeclaration,
isInternalModuleImportEqualsDeclaration,
isInTopLevelContext,
Expand Down Expand Up @@ -29879,8 +29878,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
(contextualType.pattern.kind === SyntaxKind.ObjectBindingPattern || contextualType.pattern.kind === SyntaxKind.ObjectLiteralExpression);
const inConstContext = isConstContext(node);
const checkFlags = inConstContext ? CheckFlags.Readonly : 0;
const isInJavascript = isInJSFile(node) && !isInJsonFile(node);
const enumTag = getJSDocEnumTag(node);
const isInJavascript = isInJSFile(node);
const enumTag = isInJavascript ? getJSDocEnumTag(node) : undefined;
const isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
let objectFlags: ObjectFlags = freshObjectLiteralFlag;
let patternWithComputedProperties = false;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,7 @@ namespace Parser {
contextFlags = NodeFlags.JavaScriptFile;
break;
case ScriptKind.JSON:
contextFlags = NodeFlags.JavaScriptFile | NodeFlags.JsonFile;
contextFlags = NodeFlags.JsonFile;
break;
default:
contextFlags = NodeFlags.None;
Expand Down