π Search Terms
"TS6196", "is declared but never used", "unused generic", "noUnusedParameters"
π Version & Regression Information
- This changed between versions 6.0.3 and 7.0.2
β― Playground Link
https://www.typescriptlang.org/play/?#code/C4TwDgpgBAShBmAeAKgPigXigbwFAEgA3AQwBsBXCALimQBpcBfXXecgOwGNgBLAe3ZROAJwjFgEOEnoBVKBAAeE9gBMAzlEJ8eK1AAoSFapu0qAlDSkpUAblYdu-QSLESraA2Uo1kF2Ams7Ni5eASFRcUkAj0NvWj93dDx8UWByYUFkoi8IBnxGO2ZcTgE1YChReABGTHDXKPg9MzsS9jU+UggAOlI+AHM9Sqrm4tLyyoAmWpdIq3ZyAFsAIwhhOhMdfRHW9s6e-sGECe2xioQAZmmItwD55dX9KvOTto7u3oHK57sgA
π» Code
type Ref<T> = {
value: T,
}
function createRef<T,U extends void>(value: void): Ref<T>;
function createRef<T>(value: T): Ref<T>;
function createRef<T>(value: T): Ref<T> {
return {
value,
};
}
const ref1 = createRef();
console.log(ref1);
const ref2 = createRef<number, void>();
console.log(ref2);
const ref3 = createRef<number>(13);
console.log(ref3);
π Actual behavior
The typescript compiler version 7 fails with following error message:
code.ts:5:22 - error TS6196: 'U' is declared but never used.
5 function createRef<T,U extends void>(value: void): Ref<T>;
~~~~~~~~~~~~~~
Found 1 error in code.ts:5
The typescript compiler version 6 succeeds without any errors.
π Expected behavior
The typescript compiler version 7 should behave exactly like version 6 i.e. not fail.
Additional information about the issue
This error only occurs with noUnusedParameters set to true.
π Search Terms
"TS6196", "is declared but never used", "unused generic", "noUnusedParameters"
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?#code/C4TwDgpgBAShBmAeAKgPigXigbwFAEgA3AQwBsBXCALimQBpcBfXXecgOwGNgBLAe3ZROAJwjFgEOEnoBVKBAAeE9gBMAzlEJ8eK1AAoSFapu0qAlDSkpUAblYdu-QSLESraA2Uo1kF2Ams7Ni5eASFRcUkAj0NvWj93dDx8UWByYUFkoi8IBnxGO2ZcTgE1YChReABGTHDXKPg9MzsS9jU+UggAOlI+AHM9Sqrm4tLyyoAmWpdIq3ZyAFsAIwhhOhMdfRHW9s6e-sGECe2xioQAZmmItwD55dX9KvOTto7u3oHK57sgA
π» Code
π Actual behavior
The typescript compiler version 7 fails with following error message:
The typescript compiler version 6 succeeds without any errors.
π Expected behavior
The typescript compiler version 7 should behave exactly like version 6 i.e. not fail.
Additional information about the issue
This error only occurs with
noUnusedParametersset totrue.