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

feat/typescript: add TypeScript examples to the guide #1560

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

omar-sobhy
Copy link

@omar-sobhy omar-sobhy commented May 7, 2024

Please describe the changes this PR makes and why it should be merged:

WIP WIP! I'm only opening the PR to get opinions on the current structure and suggestions on how to improve things. The current examples are slightly opinionated, but could possibly stand to be more opinionated on things like the tsconfig.json.

This PR adds TypeScript examples to the guide.

Pages now have TypeScript markdown containers when TypeScript-specific tips need to be displayed. Additionally, TypeScript examples are added to pages using code groups so that guide readers can switch between JS/TS examples on the fly.

Closes #1121

@omar-sobhy omar-sobhy changed the title Feat/typescript feat/typescript: add TypeScript examples to the guide May 7, 2024
@omar-sobhy
Copy link
Author

Something I was considering is creating an entirely separate TypeScript section in the guide and adding all the guide content there. This has the advantage of keeping the JS portion of the guide clean, but it also essentially duplicates the content

@omar-sobhy omar-sobhy marked this pull request as draft May 8, 2024 05:32
import { REST, Routes } from 'discord.js';
import { Config, assertObjectIsConfig } from './types/Config';
import fs from 'fs';
import path from 'path';
Copy link

Choose a reason for hiding this comment

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

Suggested change
import path from 'path';
import path from 'node:path';

```ts
import { REST, Routes } from 'discord.js';
import { Config, assertObjectIsConfig } from './types/Config';
import fs from 'fs';
Copy link

Choose a reason for hiding this comment

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

Suggested change
import fs from 'fs';
import fs from 'node:fs';

:::
:::code-group-item ts
```ts {1-2}
import { readFileSync } from 'fs';
Copy link

Choose a reason for hiding this comment

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

Suggested change
import { readFileSync } from 'fs';
import { readFileSync } from 'node:fs';

:::code-group-item ts
```ts {1-2}
import { readFileSync } from 'fs';
import path from 'path';
Copy link

Choose a reason for hiding this comment

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

Suggested change
import path from 'path';
import path from 'node:path';

::: code-group-item ts
```ts
import { readFileSync } from 'fs';
import path from 'path';
Copy link

Choose a reason for hiding this comment

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

Suggested change
import path from 'path';
import path from 'node:path';

:::
::: code-group-item ts
```ts
import { readFileSync } from 'fs';
Copy link

Choose a reason for hiding this comment

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

Suggested change
import { readFileSync } from 'fs';
import { readFileSync } from 'node:fs';

@ghost
Copy link

ghost commented May 25, 2024

Maybe eslint section should also include basic information about typescript-eslint too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typescript code collections
2 participants