Hack TypeScript generateCertificate parameter type
I am planning to archive the project Areditors. And develop Ateditors with TypeScript as replacement.
There is one WebRTC sync data function between editors in the Areditors. That use RTCPeerConnection.generateCertificate to manual generate X.509 certificate for DTLS connection. I use ECDSA algorithm that need additional namedCurve field.
Then I find tsc -b with parameter no match error. The type AlgorithmIdentifier define as below:
type AlgorithmIdentifier = Algorithm | string;And Algorithm only one field:
interface Algorithm {
name: string;
}Most match interface is:
interface EcKeyGenParams extends Algorithm {
namedCurve: NamedCurve;
}So I hack VSCodium TypeScript extension file(/Applications/VSCodium.app/Contents/Resources/app/extensions/node_modules/typescript/lib/lib.dom.d.ts) like below:
type AlgorithmIdentifier = Algorithm | EcKeyGenParams | string;Then the codes are clear warnings and errors.
My success code hack. I will try to commit a bug to the extension project later. Maybe that is useful to all 😊