Skip to content
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

[docs] Add Grid List TypeScript demos #15118

Merged
merged 3 commits into from
Mar 31, 2019
Merged

[docs] Add Grid List TypeScript demos #15118

merged 3 commits into from
Mar 31, 2019

Conversation

Dudrie
Copy link
Contributor

@Dudrie Dudrie commented Mar 30, 2019

This are the typescript demos for the grid list components.

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation component: image list This is the name of the generic UI component, not the React module! typescript labels Mar 30, 2019
@oliviertassinari oliviertassinari changed the title Add Grid List TypeScript demos [docs] Add Grid List TypeScript demos Mar 30, 2019
@mui-pr-bot
Copy link

mui-pr-bot commented Mar 30, 2019

No bundle size changes comparing 2c2075e...94cc041

Generated by 🚫 dangerJS against 94cc041

Copy link
Contributor

@sperry94 sperry94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good! For tileData.ts though, I would just add a tileData.d.ts file and define the type that is exported by tileData.js. That could look something like:

export interface TileDataItem {
    img: string;
    title: string;
    author: string;
    cols: number;
    featured: boolean;
}

declare const tileData: TileDataItem[];

export default tileData;

That way you don't have to redefine the values of tileData!

@Dudrie
Copy link
Contributor Author

Dudrie commented Mar 30, 2019

Everything looks good! For tileData.ts though, I would just add a tileData.d.ts file and define the type that is exported by tileData.js. That could look something like:

export interface TileDataItem {
    img: string;
    title: string;
    author: string;
    cols: number;
    featured: boolean;
}

declare const tileData: TileDataItem[];

export default tileData;

That way you don't have to redefine the values of tileData!

I liked that idea, so I tried to do it. However, after adding the definition file, docs:typescript:check reports Test file should not use a relative import. Use a global import as if this were a user of the package. See: https://github.com/Microsoft/dtslint/blob/master/docs/no-relative-import-in-test.md on all files using tileData.

The question is: How do one solve this problem?

  • Should we stick with the solution of creating the additional file (like it's done now) because the js demos get created from the ts demos so the data.
  • Or should we go with the definition file and ignore the tslint setting (which would probably cause confusion at the people reading these demos later?)? 🤔

For now, I won't change it due to the linting error.

@oliviertassinari
Copy link
Member

oliviertassinari commented Mar 30, 2019

@sperry94
Copy link
Contributor

I think that rule is there to prevent someone from adding a relative import to the component in the demo (ex: GridList), which wouldn’t be helpful to readers.

I think the inline/duplication idea might be the best option

@Dudrie
Copy link
Contributor Author

Dudrie commented Mar 30, 2019

I think that rule is there to prevent someone from adding a relative import to the component in the demo (ex: GridList), which wouldn’t be helpful to readers.

I think the inline/duplication idea might be the best option

We could get rid of the "describing comments" which describe the structure of the tileDate in the demos aswell if we go down the inline/duplication route.

Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since they are not meant to be editable in codesandbox the relative import is fine.

However disabling the lint rule for a file would need a comment which is preserved during transpilation. Does the CLI pick up an additional tslint.json in this directory that disables this rule?

I would also agree that a tileData.d.ts is sufficient. The tileData.ts is never actually used.

@oliviertassinari
Copy link
Member

Since they are not meant to be editable in codesandbox the relative import is fine.

The more demos we can run on codesandbox the better. But it does not always worth it.

@Dudrie
Copy link
Contributor Author

Dudrie commented Mar 30, 2019

@eps1lon I pushed a version with tileData.d.ts and corresponding disabling comments above the import of ./tileData. However the ts demos and js demos aren't equivalent anymore and the generated js demos would contain this comment aswell.

@eps1lon
Copy link
Member

eps1lon commented Mar 31, 2019

@Dudrie Maybe try it with a tslint.json in the directory that disables that rule.

@eps1lon eps1lon mentioned this pull request Mar 31, 2019
This replaces the disabling comments in the `.tsx` files.
@Dudrie
Copy link
Contributor Author

Dudrie commented Mar 31, 2019

@eps1lon Done 😊

@eps1lon
Copy link
Member

eps1lon commented Mar 31, 2019

@Dudrie Much appreciated! Thanks.

@Dudrie Dudrie deleted the ts-demos-grid-list branch March 31, 2019 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: image list This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants