question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

/** @deprecated */ support broken on mapped types

See original GitHub issue

Bug Report

🔎 Search Terms

vscode, jsdoc

🕗 Version & Regression Information

4.1.3

⏯ Playground Link

Playground link with relevant code

💻 Code

type ApiDict = {
  /**
   * jsdoc for getString
   */
  getString: string;
  /**
   * jsdoc for getBoolean
   * 
   * @deprecated
   */
  getBoolean: boolean;
};

type Api = {
  [key in keyof ApiDict]: {
    (url: string): ApiDict[key]; 
  };
};

declare const api: Api;
declare const api2: ApiDict;

api.getBoolean
api2.getBoolean

image

related issue

https://github.com/microsoft/TypeScript/issues/42549

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
scvnathancommented, Aug 26, 2021

Should this be expected to work then? In this contrived example, Partial and MappedType aren’t really assigning a new type to the properties, right?

function getColor(colors?: {red?: string, orangered?: string}) {  
  return {
    /** @deprecated use orangered */
    red: colors?.orangered,
    orangered: colors?.orangered,
    blue: '...'
  }
}

type MappedType<T> = { [K in keyof T]: T[K]};

type ColorResponse = Partial<ReturnType<typeof getColor>>;
type ColorResponse2 = MappedType<ReturnType<typeof getColor>>;
type ColorResponse3 = ReturnType<typeof getColor>;

const colors: ColorResponse = getColor();
const colors2: ColorResponse2 = getColor();
const colors3: ColorResponse3 = getColor();


// no strikethrough
const red = colors?.red

// no strikethrough
const red2 = colors2?.red;

// strikethrough
const red3 = colors3?.red;

// All are deprecated in popup

Either way, I find it confusing that a property can be marked as deprecated in a popup and not also include the strike-through. Why the inconsistency?

https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABAcwKZQMJwDZwE4AUEO+AzgPwBciA3nqgCZWKlR4xjIA0i+Ahp1T0m1Vu04BfAJS1EiAFBz6UEHiQ1FcxAHoAVLsQABBqgAO9CHyiNEIUql54BaYYl3bNSxtWK48FADp+QWEuT0dnIW9EXzJyIKcQxjCtRAAjbBBUagByAPyczQl5YvkoAE9TBwBZPlMqhgAVStQAHkaAPkQAXlkAbQBpRA5EAGtUcrhgREaAXWpGwdmJAG55MpbELD8AJVRSUwR7HsQABT48WD5sVr2VNWaq1oqqqZR0bfwOjrWXh0+8HsDkdUAAmE61eqMR5tO6qMAw54tN5oTAkPDfX6bAFAw5gewAZhOcIeLSRr2mqIBP3WxHxUBi6NI1Bx+zxx16VPRBCkazprEZflIoJZ6NxIPBnI+3N58n5DNi-gJot2bJBRKlaL8PLW6202kQABEzBYrDYRodTCBTDwwHAWGwYOMoAALPBwEDIF1yo4M1y9RWBYTyfVGk2oSzWBjDJCW622+1iJ3oN0er0++mIYSSwVkUHxYRrUPG8wRs3Ri1wK02h3sZ2pz3e+VZxga3NKguMFZAA

0reactions
moshestcommented, Dec 16, 2022

Think as well that deprecated keys should inherit deprecation marks from their parents.

@deprecated used to inform the user that this property will no longer exists in future versions. When this property removed, the type that used this deprecated key will also breaks so we should display this for the user as well.

Right now the inconsistent status when the tooltip showing the @deprecated comment on hover but don’t display the deprecation mark on the code feels buggy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bundle.get() deprecated. How to fix this when converting to ...
Use the type-safe specific APIs depending on the type of the item to be retrieved, eg. getString(String). So how to solve this in...
Read more >
Deprecated (Phased-out) Features and Supported Approach
Deprecated Field Rule80A (47) Value OrderC... A Agency single order A B Short exempt transaction (refer to A type) A C Program Order, non‑index arb, for...
Read more >
Deprecated Code: How Dependency Mapping Can Prevent ...
Deprecated code is a natural part of software's evolution. However, unaddressed deprecated code can lead to future code breaks and inefficient databases.
Read more >
Prettier 2.4: new bracketSameLine option and TypeScript 4.4 ...
Deprecate the jsxBracketSameLine option in favour of the new bracketSameLine option that will work for HTML, Angular, Vue, and JSX. <!-- Input ...
Read more >
Removal of mapping types | Elasticsearch Guide [8.5] | Elastic
Elasticsearch 8.0.0 no longer supports mapping types. For details on how to migrate your clusters away from mapping types, see the removal of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found