-
Notifications
You must be signed in to change notification settings - Fork 203
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
Changes from 1 commit
9b18b23
6e827f1
5cd453f
dc39854
3c78960
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,7 @@ const NotificationsWidget = () => { | |
|
||
// After three seconds, update notificationSeen (to hide red dot) | ||
useEffect(() => { | ||
// eslint-disable-next-line @typescript-eslint/no-implied-eval | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we running the linter for TS and TSX? I can't find the command being updated and changes in eslintrc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, you are right. Fixed with dc39854. Changing .eslintrc shouldn't be needed since it inherits from frontend-build which already configures eslint to support typescript. |
||
setTimeout(onNotificationSeen, 3000); | ||
sendTrackEvent('edx.ui.course.upgrade.new_sidebar.notifications', notificationTrayEventProperties); | ||
}, []); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// frontend-platform currently doesn't provide types... do it ourselves for i18n module at least. | ||
// We can remove this in the future when we migrate to frontend-shell, or when frontend-platform gets types | ||
// (whichever comes first). | ||
|
||
declare module '@edx/frontend-platform/i18n' { | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { injectIntl as _injectIntl } from 'react-intl'; | ||
/** @deprecated Use useIntl() hook instead. */ | ||
export const injectIntl: typeof _injectIntl; | ||
/** @deprecated Use useIntl() hook instead. */ | ||
export const intlShape: any; | ||
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
export { | ||
createIntl, | ||
FormattedDate, | ||
FormattedTime, | ||
FormattedRelativeTime, | ||
FormattedNumber, | ||
FormattedPlural, | ||
FormattedMessage, | ||
defineMessages, | ||
IntlProvider, | ||
useIntl, | ||
} from 'react-intl'; | ||
|
||
// Other exports from the i18n module: | ||
export const configure: any; | ||
export const getPrimaryLanguageSubtag: (code: string) => string; | ||
export const getLocale: (locale?: string) => string; | ||
export const getMessages: any; | ||
export const isRtl: (locale?: string) => boolean; | ||
export const handleRtl: any; | ||
export const mergeMessages: any; | ||
export const LOCALE_CHANGED: any; | ||
export const LOCALE_TOPIC: any; | ||
export const getCountryList: any; | ||
export const getCountryMessages: any; | ||
export const getLanguageList: any; | ||
export const getLanguageMessages: any; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "@edx/typescript-config", | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"baseUrl": "./src", | ||
"paths": { | ||
"*": ["*"], | ||
"@src/*": ["*"] | ||
} | ||
}, | ||
"include": ["*.js", ".eslintrc.js", "src/**/*", "plugins/**/*"], | ||
"exclude": ["dist", "node_modules"] | ||
} |
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.