-
Notifications
You must be signed in to change notification settings - Fork 215
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
Enable TypeScript support in this repo #1459
Merged
bradenmacdonald
merged 5 commits into
openedx:master
from
open-craft:braden/basic-typescript
Oct 7, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9b18b23
feat: turn on type checking with TypeScript
bradenmacdonald 6e827f1
refactor: add typing to sidebars
bradenmacdonald 5cd453f
chore: rename 'messages.js' to 'messages.ts'
bradenmacdonald dc39854
fix: lint .ts and .tsx files
bradenmacdonald 3c78960
chore: update with master
bradenmacdonald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import type { WIDGETS } from '@src/constants'; | ||
import type { SIDEBARS } from './sidebars'; | ||
|
||
export type SidebarId = keyof typeof SIDEBARS; | ||
export type WidgetId = keyof typeof WIDGETS; | ||
export type UpgradeNotificationState = ( | ||
| 'accessLastHour' | ||
| 'accessHoursLeft' | ||
| 'accessDaysLeft' | ||
| 'FPDdaysLeft' | ||
| 'FPDLastHour' | ||
| 'accessDateView' | ||
| 'PastExpirationDate' | ||
); | ||
|
||
export interface SidebarContextData { | ||
toggleSidebar: (sidebarId?: SidebarId | null, widgetId?: WidgetId | null) => void; | ||
onNotificationSeen: () => void; | ||
setNotificationStatus: React.Dispatch<'active' | 'inactive'>; | ||
currentSidebar: SidebarId | null; | ||
notificationStatus: 'active' | 'inactive'; | ||
upgradeNotificationCurrentState: UpgradeNotificationState; | ||
setUpgradeNotificationCurrentState: React.Dispatch<UpgradeNotificationState>; | ||
shouldDisplaySidebarOpen: boolean; | ||
shouldDisplayFullScreen: boolean; | ||
courseId: string; | ||
unitId: string; | ||
hideDiscussionbar: boolean; | ||
hideNotificationbar: boolean; | ||
isNotificationbarAvailable: boolean; | ||
isDiscussionbarAvailable: boolean; | ||
} | ||
|
||
const SidebarContext = React.createContext<SidebarContextData>({} as SidebarContextData); | ||
|
||
export default SidebarContext; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
.../new-sidebar/icons/RightSidebarFilled.jsx → .../new-sidebar/icons/RightSidebarFilled.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import * as React from 'react'; | ||
|
||
const RightSidebarFilled = (props) => ( | ||
<svg | ||
width={24} | ||
|
2 changes: 0 additions & 2 deletions
2
...ew-sidebar/icons/RightSidebarOutlined.jsx → ...ew-sidebar/icons/RightSidebarOutlined.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
import * as React from 'react'; | ||
|
||
const RightSidebarOutlined = (props) => ( | ||
<svg | ||
width={24} | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bradenmacdonald I just experimented with this and I found this to be more precise, what do you say?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems less precise to me? If you do that, the type actually just becomes this, which is basically "any object" - not very useful:
Whereas using the
satisfies
operator, we get the exactly correct type as a constant:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bradenmacdonald That makes more sense I was looking it from the point of view of just reading it, inferencing it will be more helpful for sure in the way you did it.