TypeScript Version: 3.7.x-dev.201xxxxx
Search Terms:
Code
lib.js
/** * @template T * @implements {IEncoder<T>} */exportclassEncoder{/** * @param {T} value */encode(value){returnnewUint8Array(0)}}/** * @template T * @typedef {import('./interface').Encoder<T>} IEncoder */interface.ts
exportinterfaceEncoder<T>{encode(value:T): Uint8Array}Expected behavior:
Generating typedefs should generate TS file that type checks, e.g. for lib.js it should produce something like:
/** * @template T * @implements {IEncoder<T>} */exportclassEncoderImpl<T>implementsIEncoder<T>{/** * @param {T} value */encode(value: T): Uint8Array;}import{EncoderasIEncoder}from"./interface"Actual behavior:
Instead tsc generates lib.d.ts file which does not type check, because type parameters are omitted
/** * @template T * @implements {IEncoder<T>} */exportclassEncoderImpl<T>implementsEncoder{/** * @param {T} value */encode(value: T): Uint8Array;}exporttypeIEncoder<T>=import("./interface").Encoder<T>;Playground Link:
Can't make a playground link because it requires multiple files, but here is the repo with the above example
https://github.com/Gozala/tsc-implements-bug
Related Issues:
Unfortunately it's not just that type parameters are omitted, but also the fact that importing interface turns it into a type which then can't be used as implements target.
TypeScript Version: 3.7.x-dev.201xxxxx
Search Terms:
Code
lib.jsinterface.tsExpected behavior:
Generating typedefs should generate TS file that type checks, e.g. for
lib.jsit should produce something like:Actual behavior:
Instead tsc generates
lib.d.tsfile which does not type check, because type parameters are omittedPlayground Link:
Can't make a playground link because it requires multiple files, but here is the repo with the above example
https://github.com/Gozala/tsc-implements-bug
Related Issues:
Unfortunately it's not just that type parameters are omitted, but also the fact that importing interface turns it into a type which then can't be used as implements target.