-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
TypeScript Version: 3.8.3
Search Terms:
string literal
string alias
is not assignable to parameter of type
Expected behavior:
No type check errors
Actual behavior:
No overload matches this call.
The last overload gave the following error.
Argument of type 'tAlgorithm' is not assignable to parameter of type '"oct"'.
Type '"EC"' is not assignable to type '"oct"'.
Related Issues:
Code
interface KeyStore {
generate(kty: 'EC', crv?: string, parameters?: object, isprivate?: boolean): void;
generate(kty: 'OKP', crv?: string, parameters?: object, isprivate?: boolean): void;
generate(kty: 'RSA', bitlength?: number, parameters?: object, isprivate?: boolean): void;
generate(kty: 'oct', bitlength?: number, parameters?: object): void;
}
type tAlgorithm = "RSA" | "EC" | "OKP" | "oct";
function generateKey(alg: tAlgorithm, crvOrSize: string | number) {
return ({} as KeyStore).generate(alg, crvOrSize);
}
Output
"use strict";
function generateKey(alg) {
return {}.generate(alg, "P-256");
}
Compiler Options
{
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"useDefineForClassFields": false,
"alwaysStrict": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"downlevelIteration": false,
"noEmitHelpers": false,
"noLib": false,
"noStrictGenericChecks": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"esModuleInterop": true,
"preserveConstEnums": false,
"removeComments": false,
"skipLibCheck": false,
"checkJs": false,
"allowJs": false,
"declaration": true,
"experimentalDecorators": false,
"emitDecoratorMetadata": false,
"target": "ES2017",
"module": "ESNext"
}
}
Playground Link: Provided
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug