-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
The TS4023-TS6133 Paradox (noUnusedLocals) #24287
Comments
I don't thinks that the error at Value is correct. Disabling As a workaround: import { createNamed, Named } from "./b";
export const Value: Named = createNamed(); ( |
@j-oliveras I'm aware of the fact this is caused by I'm raising this issue in hopes that we can work out a way to break the paradox, so that as one solves the chain of errors as the compiler suggests, you end up with compilable code. |
The original issue is a duplicate of #9944, and should be fixed in 2.9.1. looks like there is a diffrent bug though, the output should be: // a.d.ts
export declare const Value: import("./b").Named; and not // a.d.ts
export declare const Value: Named; |
@mhegazy ah, my bad, I didn't notice any comment indicating that it was going to get fixed. Apologies for opening a duplicate! 🙏 |
@mhegazy for TS@2.9.1 this bug still reproduced with this code (with same b.ts export {
Hash,
StringHash, StringHash2
};
interface Hash<T> {
[key: string]: T;
}
type StringHash = Hash<string>; // type NOT OK
interface StringHash2 extends Hash<string> { // interface OK
} a.ts import {StringHash, StringHash2} from "./b";
export {
doSome
}
const MAP: StringHash = {
a: "a"
};
const MAP2: StringHash2 = {
a: "a"
};
function doSome(arg1: string,
arg2 = MAP, // << type NOT OK: Error:(16, 17) TS4076: Parameter 'arg2' of exported function has or is using name 'Hash' from external module "./b" but cannot be named.
arg3 = MAP2) { // << interface OK
console.log(arg1, arg2, arg3);
} Should i start a new issue? |
yes please |
@weswigham Sorry, I did not notice your comment. |
TypeScript Version: 2.8.3
Search Terms: TS6133 TS4023
Code
tsconfig.json
src/a.ts
src/b.ts
Expected behavior:
Preferably that the compiler will know to add the import when emitting declarations (which I am aware is the root cause of the error in the first example).
If that's not possible, then the compiler should not trigger a warning for imported types that are used for declaration emission only.
Actual behavior:
The compiler reports an error when not importing types that get implicitly exported. When adding the import to satisfy that requirement, the compiler errors because of the
noUnusedLocals
option. Removing the unused local (the import) causes the first error, hence the reason I aptly labeled this a paradox.Playground Link: This error requires the use of multiple files. Therefore I have attached screenshots and sources that can be used to reproduce the exact setup.
Related Issues: #5711, #9944
The text was updated successfully, but these errors were encountered: