microsoft / microsoft/TypeScript

function object parameter destructure field without default value will be ignored

Aperta
#59,920 7 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@jakebailey ci sta già lavorando.

Dal 10/9/2024.

Bug Domain: JavaScript
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔎 Search Terms

js, function, parameter, destructure, required

🕗 Version & Regression Information
  • This changed between versions 5.6 and latest nightly
  • We use ts 5.5 no this issue, after upgrade this issue occur.
⏯ Playground Link
💻 Code
// utils.js

export const getUserProfileByUsername = ({
  username,
  withEmail = false,
  withNotificationSettings = false,
} = {}) => {
  return {};
};
// main.ts
import { getUserProfileByUsername } from './utils';

getUserProfileByUsername({
  username: 'ly',
});
🙁 Actual behavior
src/main.ts:4:3 - error TS2353: Object literal may only specify known properties, and 'username' does not exist in type '{ withEmail?: boolean | undefined; withNotificationSettings?: boolean | undefined; }'.

4   username: 'ly',
    ~~~~~~~~


Found 1 error in src/main.ts:4
🙂 Expected behavior

no ts validate error

Additional information about the issue

ts 5.x not this issue, must be introduced by 5.6

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.