microsoft / microsoft/TypeScript
checkJs can't correctly determine type of generic function parameter
Aperta
@ahejlsberg ci sta già lavorando.
Dal 12/6/2019.
Suggestion
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
TypeScript Version: 3.4.5
jsdoc
checkJs
template
function
parameter
/**
* @template T
* @param {(left: T, right: T) => boolean} equals
* @returns {(xs: T[]) => T[]}
*/
const uniq = equals => xs => {
/** @type {T[]} */
const seen = []
const out = []
const len = xs.length
let j = 0
for(let i = 0; i < len; i++) {
const item = xs[i]
if(!seen.some(s => equals(s, item))) {
seen.push(item)
out[j++] = item
}
}
return out;
}
uniq((x, y) => x == y)([1, 3, 3, 7])
Expected behavior:
Typechecks fine
Actual behavior:
Type 'number' is not assignable to type 'T
Related Issues:
This seems related, but I don't think it's it
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.