Typescript: "All declarations must have identical modifiers" error only changed in one place with `--watch`

Created on 11 Aug 2018  ·  4Comments  ·  Source: microsoft/TypeScript

TypeScript Version: 3.1.0-dev.20180810

Search Terms:

Code

a.ts:

interface Document {
    fullscreen: boolean;
}

tsconfig.json: {}

Run tsc --watch. See errors in a.ts and lib.dom.d.ts since fullscreen must be readonly.
Change a.ts to say readonly fullscreen: boolean;.

Expected behavior:

No error.

Actual behavior:

Still an error in lib.dom.d.ts.

Error goes away when restarting tsc --watch.

Bug Fixed

Most helpful comment

@xgqfrms name conflict – there is a Response interface defined in lib.dom.d.ts and status there has different access modifier than in yours:
```ts
/** The Response interface of the Fetch API represents the response to a request. */
interface Response extends Body {
readonly headers: Headers;
readonly ok: boolean;
readonly redirected: boolean;
readonly status: number;
readonly statusText: string;
readonly trailer: Promise;
readonly type: ResponseType;
readonly url: string;
clone(): Response;
}

All 4 comments

Right now we do not generate errors in lib file even if change is in non module file, and fix would be to remove cached diagnostics in lib file if change is in non module file.

what's wrong with this?

All declarations of 'status' must have identical modifiers.

image

http://www.typescriptlang.org/play/index.html#src=%2F%2F%20%60Response%60%20will%20be%20defined%20here...%0D%0Ainterface%20Response%20%7B%0D%0A%20%20%20%20%2F%2F%20Some%20HTTP%20status%20code%2C%20such%20as%20200%0D%0A%20%20%20%20status%3A%20number%2C%0D%0A%20%20%20%20%2F%2F%20All%20declarations%20of%20'status'%20must%20have%20identical%20modifiers%20%3F%3F%3F%0D%0A%7D%0D%0A%0D%0Alet%20log%20%3D%20console.log%3B%0D%0Alet%20error%20%3D%20console.error%3B%0D%0Alet%20warn%20%3D%20console.warn%3B%0D%0A%0D%0Afetch(%22https%3A%2F%2Fblogs.xgqfrms.xyz%2Ffoo%2Fbar%22)%0D%0A.then((res%3A%20Response)%20%3D%3E%20%7B%0D%0A%20%20%20%20let%20json%20%3D%20%7B%7D%3B%0D%0A%20%20%20%20log(res.status)%0D%0A%20%20%20%20if%20(res.status%20%3D%3D%3D%20200)%20%7B%0D%0A%20%20%20%20%20%20%20%20json%20%3D%20res.json()%3B%0D%0A%20%20%20%20%7D%20else%20%7B%0D%0A%20%20%20%20%20%20%20%20%2F%2F%20json%20%3D%20%7B%7D%3B%0D%0A%20%20%20%20%7D%0D%0A%20%20%20%20return%20json%3B%0D%0A%7D)%0D%0A.then(json%20%3D%3E%20log(%60fetch%20json%20%3D%60%2C%20JSON.stringify(json%2C%20null%2C%204)))%0D%0A.catch(err%20%3D%3E%20error(%60fetch%20error%3A%60%2C%20err))%3B%0D%0A

@xgqfrms name conflict – there is a Response interface defined in lib.dom.d.ts and status there has different access modifier than in yours:
```ts
/** The Response interface of the Fetch API represents the response to a request. */
interface Response extends Body {
readonly headers: Headers;
readonly ok: boolean;
readonly redirected: boolean;
readonly status: number;
readonly statusText: string;
readonly trailer: Promise;
readonly type: ResponseType;
readonly url: string;
clone(): Response;
}

Over at DefinitelyTyped/DefinitelyTyped#15104, this issue is being discussed without figuring a solution being provided that works for everyone. Can you please weigh in with which package upgrade, configuration or whatever is required to fix this problem permanently for everyone?

Was this page helpful?
0 / 5 - 0 ratings