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.

[Question] How to modify a property of a type alias?

See original GitHub issue

I would like to go through all types and interfaces and replace the property member if it exists. So I would like to change

interface X {
    member: OldMember;
    otherStuff: ...
}
type Y = {
    member: OldMember;
    otherStuff: ...
}

to

interface X {
    member: NewMember;
    otherStuff: ...
}
type Y = {
    member: NewMember;
    otherStuff: ...
}

For interfaces, I found I can do i.getProperty('member').set({ type: "NewMember" }), but I was struggling to find the equivalent functions for types. What am I missing?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
dsherretcommented, May 10, 2020

No problem! Not much else to do right now haha 😄

0reactions
binoche9commented, May 10, 2020

Ah that did the trick. Thank you for walking me through it! Plus the amazing response time!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modify a TypeScript type alias from @types type - Stack Overflow
Using Typescript 3, I'm using a definition from DefinitelyTyped but I need to edit a type alias. I am using @types/json-schema for the...
Read more >
Creating type aliases - Learn TypeScript
Using type aliases for functions​​ type TypeAliasName = (paramName1: paramType1, ...) => ReturnType; Copy the function below and paste it in the code...
Read more >
How To Use Type Aliases in TypeScript - DigitalOcean
In this tutorial, you will refactor code that uses string literals to include aliases. You will be able to use and understand TypeScript...
Read more >
Type Aliases vs Interfaces in TypeScript - DEV Community ‍ ‍
Type aliases are declared with the type keyword preceding them. Think of them like regular JavaScript variables that are used to represent ...
Read more >
How to Override Specific Property Types Using TypeScript
Override specific property type annotations using mapped, conditional, and intersection types with TypeScript for interfaces or classes.
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