-
Notifications
You must be signed in to change notification settings - Fork 503
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
style(typescript): enable strict except noImplicitAny and strictNullChecks #7559
Conversation
Great initiative, we definitely want this! However, it's probably more realistic to enable |
I just tried updating some of the sub-configs with {
"extends": "../tsconfig.json",
"include": ["."],
"compilerOptions": {
"strict": true
}
} But it doesn't seem to have any affect |
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.
Note that I'm fixing/ignoring the other warnings in #7601.
subpages(path, depth, self) { | ||
return this.page.subpagesExpand(path, depth, self); | ||
subpages(this: KumaThis, path, depth, self) { | ||
return (this.page as any).subpagesExpand(path, depth, self); |
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.
I don't know why this.page
doesn't work, possibly because this.page
refers to what this
would be without specifying this: KumaThis
. 🤷
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.
Is the this.page.subpagesExpanded
needed vs this.subpagesExpanded
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.
Haven't tried, but it looks like all those methods get called using Function.call()
with the environment ("KumaThis") as argThis
.
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.
this.page.XXX
is needed because this
is not the page
when this function is called, as per the above statement. TypeScript doesn't like this since we're essentially overwriting the variable with a new value, hence the need to cast to any
here.
@@ -164,7 +173,7 @@ const web = { | |||
flawAttribute = ` data-flaw-src="${util.htmlEscape(flaw.macroSource)}"`; | |||
} | |||
// Let's get a potentially localized title for when the document is missing. | |||
const titleWhenMissing = this.mdn.getLocalString( | |||
const titleWhenMissing = (this.mdn as any).getLocalString( |
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.
This is similar to the previous issue, except that this.web.getJSONData()
works here (although this.web
is the self-reference here) whereas this.mdn.getLocalString()
doesn't. 😕
// If the path ends with a slash, remove it. | ||
if (path.substr(-1, 1) === "/") { | ||
path = path.slice(0, -1); | ||
} | ||
|
||
const pages = this.page.subpages(path, depth, self); | ||
const pages = (this.page as any).subpages(path, depth, self); |
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.
ditto
These are now set in the parent tsconfig.json.
I triggered a dev build to make sure this doesn't break anything: https://github.com/mdn/yari/actions/runs/3497657664 |
Dev build for fc0cdc9 was deployed to: https://pr7559.content.dev.mdn.mozit.cloud/ |
LGTM |
Now covered by `strict`
Pushed one change, that shouldn't change the testing. https://www.typescriptlang.org/tsconfig/#strictBindCallApply is not already turned on by |
Summary
ESLint is checking a bunch more on the TS files, but there are still some things that the compiler is suppressing. With just
strict
there were 800+ issues, but with the other 2 options it's down to 76Problem
Solution
Either the remaining issues could be suppressed inline or addressed before landing this
Screenshots
Before
After
How did you test this change?