Skip to content

add better handling for typescript compiler #2088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

Jordan-Hall
Copy link

@Jordan-Hall Jordan-Hall commented Jun 10, 2022

fix: soft file there is no props defined

Check if export is either a class or function that returns JSX element
This allows for none exported JSX functions in the file.

For example if you had the following file:

import React from "react";
import DropdownArrowDown from '../dropdownArrowDown';
import { AutoCompleteOptions, AutoCompleteValue, RealAutoCompleteOptions } from "./types";


export interface AutoCompleteTypes {
    id: string;
    autoselect: boolean;
}

export const autoCompleteDefaultProps: Partial<AutoCompleteTypes> = {
    autoselect: false,
};


export const AutoComplete = (props:AutoCompleteTypes) => {...}

The export default would crash and file due to not having props. Now it will check its a function or a class before trying to convert to dash py

@Jordan-Hall
Copy link
Author

@T4rk1n before i carry on and add Unit test for these. This is what I was thinking to solve #2066 (comment). The error comes from not checking the type is related to JSX before trying to work out the props.

export const defaultProps = {
   address: "abc...."
}

would cause the complier to break. So while i was at it, i thought its best to check the return type is an element. If this is ok, I'll take a look at how to add support for multiple components in a single file. Currently you always override the docs each time which isn't ideal

@Jordan-Hall
Copy link
Author

The failed unit test relates to JSX just returning null. In real world I can't ever expect it not to be Element. But happy to remove that extra check for JSX

@T4rk1n
Copy link
Contributor

T4rk1n commented Jun 10, 2022

@T4rk1n before i carry on and add Unit test for these. This is what I was thinking to solve #2066 (comment). The error comes from not checking the type is related to JSX before trying to work out the props.

export const defaultProps = {
   address: "abc...."
}

would cause the complier to break. So while i was at it, i thought its best to check the return type is an element. If this is ok, I'll take a look at how to add support for multiple components in a single file. Currently you always override the docs each time which isn't ideal

The failed unit test relates to JSX just returning null. In real world I can't ever expect it not to be Element. But happy to remove that extra check for JSX

Seems ok, just make sure that null is also a valid return type, some components don't need to render anything (eg: dcc.Store) and thus return null.

@Jordan-Hall Jordan-Hall marked this pull request as ready for review June 10, 2022 15:18
@gvwilson gvwilson changed the title WIP: feat: add better handing for typescript complier WIP: feat: add better handing for typescript compiler Jul 24, 2024
@gvwilson gvwilson self-assigned this Jul 24, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson changed the title WIP: feat: add better handing for typescript compiler add better handing for typescript compiler Aug 13, 2024
@gvwilson gvwilson added infrastructure build process etc. feature something new P2 considered for next cycle community community contribution labels Aug 13, 2024
@gvwilson
Copy link
Contributor

@T4rk1n can you please take another look at this one in cycle 17? thanks - @gvwilson

@Jordan-Hall
Copy link
Author

I'm happy to take a look and make any changes

fix: soft file there is no props defined

Check if export is either a class or  function that returns JSX element
This allows for none exported JSX functions in the file.

Signed-off-by: Jordan Hall <[email protected]>
@Jordan-Hall Jordan-Hall force-pushed the ts-handle-none-component-export branch from d7dc72b to 4f6a6a4 Compare August 30, 2024 22:09
@Jordan-Hall Jordan-Hall force-pushed the ts-handle-none-component-export branch from 4f6a6a4 to 8339740 Compare August 30, 2024 22:48
@gvwilson gvwilson changed the title add better handing for typescript compiler add better handling for typescript compiler Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community community contribution feature something new infrastructure build process etc. P2 considered for next cycle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants