Skip to content
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

TS4076 Paradox (noUnusedLocals) Part 2 #24603

Closed
tsofist opened this issue Jun 1, 2018 · 1 comment
Closed

TS4076 Paradox (noUnusedLocals) Part 2 #24603

tsofist opened this issue Jun 1, 2018 · 1 comment

Comments

@tsofist
Copy link

tsofist commented Jun 1, 2018

TypeScript Version: 2.9.1

Problem is not reproduced in 3.0.0-dev.20180601

tsconfig

{
  "compilerOptions": {
    "strict": true,
    "strictNullChecks": true,
    "sourceMap": true,
    "declaration": true, // ← IMPORTANT
    "noUnusedLocals": true, // ← IMPORTANT
    "noEmit": true
  },
  "include": [
    "src"
  ],
  "exclude": [
    "node_modules"
  ]
}

Code

moduleA.ts

export {
    Hash, IStringHash, TStringHash
}

interface Hash<T> {
    [key: string]: T;
}

interface IStringHash extends Hash<string> {
}

type TStringHash = Hash<string>;

moduleB.ts

import {TStringHash, IStringHash} from "./moduleA";

const C_TYPE: TStringHash = {};
const C_INTF: IStringHash = {};

export function doSome(stub: string,
                       // ↓↓↓ No error due to explicitly specified type TStringHash
                       viaType0: TStringHash = C_TYPE,
                       viaInterface0: IStringHash = C_INTF,
                       // ↓↓↓ TS4076: Parameter 'viaType1' of exported function has or is using name 'Hash' from external module "./src/moduleA" but cannot be named.
                       viaType1 = C_TYPE,
                       viaInterface = C_INTF) {
    console.log(viaType0, viaType1, viaInterface0, viaInterface);
}

moduleC.ts

import {
    Hash, // ←←← Dubious decision. TS6133: 'Hash' is declared but its value is never read.
    TStringHash, IStringHash
} from "./moduleA";

const C_TYPE: TStringHash = {};
const C_INTF: IStringHash = {};

export function doSome(stub: string,
                       viaType0: TStringHash = C_TYPE,
                       viaInterface0: IStringHash = C_INTF,
                       // ↓↓↓ No error due to imported Hash
                       viaType1 = C_TYPE,
                       viaInterface = C_INTF) {
    console.log(viaType0, viaType1, viaInterface0, viaInterface);
}

Expected behavior:
No errors in moduleB.ts

Actual behavior:
Error in moduleB.ts: TS4076: Parameter 'viaType1' of exported function has or is using name 'Hash' from external module "./src/moduleA" but cannot be named.

Related Issues: #24287

@tsofist
Copy link
Author

tsofist commented Jun 14, 2018

Solved by 2.9.2
Thanks!

@tsofist tsofist closed this as completed Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant