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.

Extends external/imported interfaces/types

See original GitHub issue

I see in this plugin test fixtures that it supports generating propTypes from interfaces extending other interface, but only if the extended interface is in the same file.

Is it possible to do the same when the type/interface extends external imported interfaces? Or does this depend on the WIP feature typeCheck?

import React from 'react';
import { AProps, BProps } from './types';

export interface Props extends AProps, BProps {
  name: string;
}

export default function FuncExtendedInterfaces(props: Props) {
  return null;
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:19 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
danReynoldscommented, Mar 26, 2020

I found this lib: https://github.com/merceyz/typescript-to-proptypes which uses the TS compiler to support conversion of both local and external interfaces. It didn’t match quite my use case (I didn’t want to mutate the input files) and didn’t include a script for generation (just an API), so bundled that into this lib: https://github.com/danReynolds/typescript-proptypes-generator that builds on it for the general purpose of converting TS files containing types/interfaces into an equivalent JS file with propTypes. Use/reference either as needed!

2reactions
milesjcommented, Feb 26, 2021

@ethanshar No update. Honestly, I’ll probably never have time to get around to it to do it correctly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to extend an interface declared in an external library d ...
Use the newly defined types from the extended module. ... import 'react'; declare module 'react' { interface OlHTMLAttributes<T> { type?:
Read more >
How to extend interfaces declared in external libraries ...
Learn how to extend interfaces declared in external libraries in Typescript by using module augumentation.
Read more >
TypeScript Interface Merging And Extending Modules
In the plugin repository types we set things up like shown below. We import 'filepond' and then, declare a module under the same...
Read more >
Extending object-like types with interfaces in TypeScript
Extending object-like types with interfaces in TypeScript · Option 1: Declaration merging · Declaration merging to wrangle disparate user ...
Read more >
import type can't be used with interface extends #36478
Actual behavior: error TS1361: 'monaco' cannot be used as a value because it was imported using 'import type'. 24 interface MyViewZone extends ......
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