microsoft / microsoft/TypeScript

Incorrect ts(7053) error when updating json file

Open
#43,016 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Bug Report

I have strings stored in a json file.
I did set "resolveJsonModule": true, in the tsconfig.
I import the strings as follows:
import * as strings from '../languages/en.json';

Works perfectly.

When I add a string in the json file and I then try to use that new string, intellisense always gives me the ts(7053) error.

Everything builds and works but the code remains underlined as a problem.

The only workaround I found to get rid of the incorrect report is to close VSCode and reopen it.

Broken in TypeScript v4.1.5
Works in TypeScript v4.0.5

VS Code
Version: 1.53.2
Commit: 622cb03f7e070a9670c94bae1a45d78d7181fbd4
Date: 2021-02-11T11:45:54.515Z
Electron: 11.2.1
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Darwin x64 20.3.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with resolveJsonModule enabled, an imported JSON file, and a newly added string, comparing TypeScript 4.1.5 with 4.0.5. Start by examining the language-service behavior behind the ts(7053) diagnostic and verify that the diagnostic clears without restarting VS Code when the JSON changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers, developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.