-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 "strict" mode for runtime code. #3899
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d91eb58
Update std/manual.md
maxmellen d8a7858
Enable "strict" mode for runtime code.
kitsonk e98afdf
Update codebase to support TypeScript strict mode
maxmellen 08c3f1f
squash! Update codebase to support TypeScript strict mode
maxmellen f958adf
squash! Update codebase to support TypeScript strict mode
maxmellen d538cf9
squash! Update codebase to support TypeScript strict mode
maxmellen a907271
squash! Update codebase to support TypeScript strict mode
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// @ts-nocheck | ||
const importObject = Object.create(null); | ||
//IMPORTS | ||
|
||
|
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
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
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
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 |
---|---|---|
|
@@ -4,8 +4,11 @@ import { test, assertEquals } from "./test_util.ts"; | |
test(function addEventListenerTest(): void { | ||
const document = new EventTarget(); | ||
|
||
// @ts-ignore tests ignoring the type system for resilience | ||
assertEquals(document.addEventListener("x", null, false), undefined); | ||
// @ts-ignore | ||
assertEquals(document.addEventListener("x", null, true), undefined); | ||
// @ts-ignore | ||
assertEquals(document.addEventListener("x", null), undefined); | ||
}); | ||
|
||
|
@@ -14,7 +17,7 @@ test(function constructedEventTargetCanBeUsedAsExpected(): void { | |
const event = new Event("foo", { bubbles: true, cancelable: false }); | ||
let callCount = 0; | ||
|
||
const listener = (e): void => { | ||
const listener = (e: Event): void => { | ||
assertEquals(e, event); | ||
++callCount; | ||
}; | ||
|
@@ -34,11 +37,19 @@ test(function constructedEventTargetCanBeUsedAsExpected(): void { | |
|
||
test(function anEventTargetCanBeSubclassed(): void { | ||
class NicerEventTarget extends EventTarget { | ||
on(type, callback?, options?): void { | ||
on( | ||
type: string, | ||
callback: (e: Event) => void | null, | ||
options?: __domTypes.AddEventListenerOptions | ||
): void { | ||
this.addEventListener(type, callback, options); | ||
} | ||
|
||
off(type, callback?, options?): void { | ||
off( | ||
type: string, | ||
callback: (e: Event) => void | null, | ||
options?: __domTypes.EventListenerOptions | ||
): void { | ||
this.removeEventListener(type, callback, options); | ||
} | ||
} | ||
|
@@ -60,8 +71,11 @@ test(function anEventTargetCanBeSubclassed(): void { | |
|
||
test(function removingNullEventListenerShouldSucceed(): void { | ||
const document = new EventTarget(); | ||
// @ts-ignore | ||
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. again, what are we ignoring and why? 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. Same issue as #3899 (comment) |
||
assertEquals(document.removeEventListener("x", null, false), undefined); | ||
// @ts-ignore | ||
assertEquals(document.removeEventListener("x", null, true), undefined); | ||
// @ts-ignore | ||
assertEquals(document.removeEventListener("x", null), undefined); | ||
}); | ||
|
||
|
@@ -70,7 +84,7 @@ test(function constructedEventTargetUseObjectPrototype(): void { | |
const event = new Event("toString", { bubbles: true, cancelable: false }); | ||
let callCount = 0; | ||
|
||
const listener = (e): void => { | ||
const listener = (e: Event): void => { | ||
assertEquals(e, event); | ||
++callCount; | ||
}; | ||
|
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
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.
There should be a way to type it so we don't need the ignore.
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.
Similarly to #3899 (comment), the time of the argument passed to
console[method]
still wouldn't be correct so I'm not sure how to improve on this.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 think you would have to do something like to remove the
@ts-ignore
: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.
If I type
methods
asArray<keyof typeof Console>
(apparentlyConsole
refers to a value in this context) I then get the following error:And even if we got over that error, then we'd have the issue that
{ toString(): void { hasCalled = true; } }
wouldn't be considered a valid argument to these functions anyway (for instance,count
only accepts a string), so I think the best thing to do is switchmethods
back to implicitly be of typestring[]
as before my changes and keep the@ts-ignore
.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.
🤷♂ ok! you win! :-D