Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

import("../ripple") in type declaration files #857

Closed
ghost opened this issue May 8, 2019 · 10 comments
Closed

import("../ripple") in type declaration files #857

ghost opened this issue May 8, 2019 · 10 comments

Comments

@ghost
Copy link

ghost commented May 8, 2019

There is an issue with the declaration files provided with v0.12.0 where any component that uses the withRipple HOC will have a declaration file that includes import("../ripple"). This causes our type checks to fail since it can't resolve the relative import.

$ tsc
node_modules/@material/react-button/dist/index.d.ts:21:4759 - error TS2307: Cannot find module '../ripple'.

The workaround for anyone having this issue is to add "skipLibCheck": true to your tsconfig.json

@moog16
Copy link

moog16 commented May 8, 2019

@ben-mckernan thanks for opening the issue. This is the react-button/dist/index.d.ts file that I imported from 0.12.0:


import React from 'react';
import { InjectedProps } from '@material/react-ripple';
declare type ButtonTypes = HTMLAnchorElement | HTMLButtonElement;
export interface ButtonProps<T extends ButtonTypes> extends InjectedProps<T>, React.AnchorHTMLAttributes<T>, React.ButtonHTMLAttributes<T> {
    raised?: boolean;
    unelevated?: boolean;
    outlined?: boolean;
    dense?: boolean;
    disabled?: boolean;
    className?: string;
    icon?: React.ReactElement<React.HTMLProps<HTMLOrSVGElement>>;
    href?: string;
    trailingIcon?: React.ReactElement<React.HTMLProps<HTMLOrSVGElement>>;
}
export declare const Button: {
    <T extends ButtonTypes>({ className, raised, unelevated, outlined, dense, disabled, icon, href, children, initRipple, trailingIcon, unbounded, ...otherProps }: ButtonProps<T>): JSX.Element;
    defaultProps: {
        initRipple: () => void;
    };
};
declare const _default: React.ComponentType<Pick<ButtonProps<ButtonTypes>, "download" | "name" | "rel" | "target" | "type" | "accessKey" | "dir" | "draggable" | "hidden" | "lang" | "title" | "id" | "prefix" | "slot" | "children" | "contentEditable" | "inputMode" | "tabIndex" | "href" | "form" | "formAction" | "formMethod" | "formNoValidate" | "formTarget" | "value" | "raised" | "unelevated" | "outlined" | "dense" | "icon" | "trailingIcon" | "hrefLang" | "media" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | ...
export default _default;

I see '@material/react-ripple', but no ../ripple. Am I looking at the right file that you're refering to?

@ghost
Copy link
Author

ghost commented May 9, 2019

It is not at the top of the file but rather at the end of the second to last line, the line starting with declare const _default.

It is cut off in your code snippet. Here is a link to the full file on npm https://unpkg.com/@material/react-button@0.12.1/dist/index.d.ts

@moog16
Copy link

moog16 commented May 9, 2019

Confirmed. This is actually happening for all components that use the withRipple() mixin. I'm not sure why it isn't using the @material/react-ripple import path. This is definitely a bug with the types.

@arichiv
Copy link
Contributor

arichiv commented May 31, 2019

@moog16
Copy link

moog16 commented May 31, 2019

@arichiv yes no one was able to work on this just yet. Do you have time for a PR? :)

@arichiv
Copy link
Contributor

arichiv commented May 31, 2019

I walked right into that one.

I should have time to write a test to detect this next week. If that uncovers a root cause I would fix it, but I may have to stop there.

@moog16
Copy link

moog16 commented Jun 1, 2019

Sounds good! Anything is appreciated!

@arichiv
Copy link
Contributor

arichiv commented Jun 7, 2019

Ping on review for #900 :-)

@moog16
Copy link

moog16 commented Jun 10, 2019

Hey! Sorry I was out on vacation and will take a look shortly

@moog16
Copy link

moog16 commented Jun 17, 2019

Closing for #936

@moog16 moog16 closed this as completed Jun 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants