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

Enable strictFunctionTypes #49929

Merged
merged 112 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from 110 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
cd19de3
Fix some easy SFT problems
jakebailey Sep 17, 2022
666fcf8
More SFT work
jakebailey Sep 17, 2022
9e58a39
More fixes
jakebailey Sep 17, 2022
77be346
Fix emitter, checker
jakebailey Sep 17, 2022
7061fdb
Fix some more node problems
jakebailey Sep 17, 2022
82bf75b
Parser tweaks
jakebailey Sep 17, 2022
41c4a62
Resolve TODO
jakebailey Sep 17, 2022
8bc26db
More fixes
jakebailey Sep 17, 2022
f985655
Fix es2015
jakebailey Sep 17, 2022
79740c8
Fix all except visitNodes problems
jakebailey Sep 17, 2022
61fbef4
Cast to fix type guard arrow function problem
jakebailey Sep 17, 2022
1b3bd51
Completely overhaul node visitor stuff, untested
jakebailey Sep 18, 2022
9d3b851
Make non-API tests pass without SFT, found some bugs
jakebailey Sep 18, 2022
8bcad61
Wacky Visitor types
jakebailey Sep 19, 2022
f2e34f1
It compiles
jakebailey Sep 19, 2022
e88bc11
Write some jsdoc, update baselines
jakebailey Sep 19, 2022
c31d0a6
Fix lint
jakebailey Sep 19, 2022
5df975b
Actually fix lint
jakebailey Sep 19, 2022
b114cea
PR feedback
jakebailey Sep 19, 2022
88034eb
Allow non-guards as test parameter
jakebailey Sep 19, 2022
fcda16e
Actually, maybe this does fix Transform
jakebailey Sep 19, 2022
e7cf213
Update baselines
jakebailey Sep 19, 2022
186749e
Merge branch 'main' into enable-strict-function-types
jakebailey Sep 19, 2022
2ed2e92
Update comment
jakebailey Sep 19, 2022
9ae68fd
Resolve a TODO
jakebailey Sep 20, 2022
8b1efc1
Remove already resolved TODO
jakebailey Sep 20, 2022
eff9485
More todo updats
jakebailey Sep 20, 2022
3a5d135
Fix my lint oops
jakebailey Sep 20, 2022
5a609b9
Merge branch 'main' into enable-strict-function-types
jakebailey Sep 20, 2022
59a3189
Much improved NodeVisitor and NodesVisitor
jakebailey Sep 21, 2022
5bf42fa
Resolve some TODOs
jakebailey Sep 21, 2022
00a0f3e
Tweaks
jakebailey Sep 21, 2022
c053b89
Merge branch 'main' into enable-strict-function-types
jakebailey Sep 21, 2022
693b9f0
Remove TVisited for nodesVisitor
jakebailey Sep 22, 2022
0d94fe0
Copy rules to visit functions
jakebailey Sep 22, 2022
9876a57
Fixups
jakebailey Sep 22, 2022
721ed63
Simplify other implementations of NodeVisitor and NodesVisitor, now t…
jakebailey Sep 22, 2022
4329b73
Restore undefined-ness of original Visitor type
jakebailey Sep 22, 2022
45c2ca8
Make fixes more consistent
jakebailey Sep 22, 2022
d1a95df
Lint fix
jakebailey Sep 22, 2022
65ad1d3
Address some TODOs
jakebailey Sep 22, 2022
7a4a2c2
Shift around TODO
jakebailey Sep 22, 2022
52ca3a6
Add a clarifying JSDoc comment to isParameterDeclaration
jakebailey Sep 22, 2022
a0af83b
Cleanups and reverts
jakebailey Sep 22, 2022
bfee29b
Merge branch 'main' into enable-strict-function-types
jakebailey Sep 22, 2022
d263e9b
Move the undefined into the VisitResult
jakebailey Sep 22, 2022
982c706
Resolve a TODO
jakebailey Sep 22, 2022
fce72fe
Change the other VisitResult uses for consistency
jakebailey Sep 22, 2022
cd4aa3c
Cleanups
jakebailey Sep 22, 2022
734c58f
Eliminate isArrayOf
jakebailey Sep 22, 2022
1b7fbeb
Remove cast for byteLength by using BufferEncoding type
jakebailey Sep 22, 2022
a4874b1
Remove checks
jakebailey Sep 22, 2022
d3c8231
Resolve some TODOs
jakebailey Sep 22, 2022
76ca962
Fix lint
jakebailey Sep 22, 2022
8fae2ca
Merge branch 'main' into enable-strict-function-types
jakebailey Sep 24, 2022
8f4f9ee
Merge branch 'main' into enable-strict-function-types
jakebailey Sep 26, 2022
b95dc38
Mark new helper as internal
jakebailey Sep 26, 2022
65cf0f8
Merge branch 'main' into enable-strict-function-types
jakebailey Oct 1, 2022
29da028
Merge branch 'main' into enable-strict-function-types
jakebailey Oct 20, 2022
46a5d91
Duplicate jsdoc
jakebailey Oct 20, 2022
f89c0c4
Accept baselines
jakebailey Oct 20, 2022
9d81f75
Merge branch 'main' into enable-strict-function-types
jakebailey Oct 27, 2022
56f36a5
Fix recent bug found by SFT
jakebailey Oct 27, 2022
5061ebb
Merge branch 'main' into enable-strict-function-types
jakebailey Nov 2, 2022
9e6837d
Merge branch 'main' into enable-strict-function-types
jakebailey Nov 5, 2022
8e8d706
Fix compiler error
jakebailey Nov 5, 2022
9eb2720
Remove unused Parent type param
jakebailey Nov 7, 2022
1ba329e
Merge branch 'main' into enable-strict-function-types
jakebailey Nov 7, 2022
b5b49ce
Merge branch 'main' into enable-strict-function-types
jakebailey Nov 8, 2022
8d17434
Fix merge issues
jakebailey Nov 8, 2022
edba1cc
Merge branch 'main' into enable-strict-function-types
jakebailey Nov 9, 2022
a1c5eca
Fix test
jakebailey Nov 9, 2022
5f595b7
Merge branch 'main' into enable-strict-function-types
jakebailey Nov 9, 2022
1accebd
Fix merge
jakebailey Nov 9, 2022
7d14f62
Merge branch 'main' into enable-strict-function-types
jakebailey Nov 11, 2022
a464d1f
Merge branch 'main' into enable-strict-function-types
jakebailey Nov 15, 2022
096bf30
Fix old merge oops
jakebailey Nov 15, 2022
97cad23
Merge branch 'main' into enable-strict-function-types
jakebailey Nov 16, 2022
a401217
Fix spacing problems caused by merge oops
jakebailey Nov 16, 2022
ba87ccf
Drop some new calls to Debug.type
jakebailey Nov 17, 2022
2f192b9
Remove my leftover comment
jakebailey Nov 17, 2022
a8608d6
Merge branch 'main' into enable-strict-function-types
jakebailey Nov 17, 2022
e0dcfb1
Fix formatting and export oops
jakebailey Nov 17, 2022
e52a85a
More PR fixups
jakebailey Nov 17, 2022
78459ba
Merge branch 'main' into enable-strict-function-types
jakebailey Nov 17, 2022
5b54712
fix missed lint
jakebailey Nov 17, 2022
2bb1554
Fix dts
jakebailey Nov 17, 2022
e14a8a6
Restore old transformer signatures
jakebailey Nov 17, 2022
6e9ef92
Merge branch 'main' into enable-strict-function-types
jakebailey Nov 17, 2022
cd58e0f
Fix post merge
jakebailey Nov 17, 2022
10393c8
Merge branch 'main' into enable-strict-function-types
jakebailey Dec 6, 2022
2a1c1f1
Fix bad merge
jakebailey Dec 6, 2022
75b300e
Merge branch 'main' into enable-strict-function-types
jakebailey Dec 13, 2022
71d3eac
Restore old cast and tryCast
jakebailey Dec 18, 2022
0c38a85
Merge branch 'main' into enable-strict-function-types
jakebailey Dec 18, 2022
828abf2
Fix new error
jakebailey Dec 18, 2022
9ee1691
Merge branch 'main' into enable-strict-function-types
jakebailey Jan 4, 2023
cd92e04
Eagerly test visited nodes during visitArray
jakebailey Jan 5, 2023
e7fa691
Merge branch 'main' into enable-strict-function-types
jakebailey Jan 8, 2023
a6f6ebb
Remove parameters fixed by future LKG
jakebailey Jan 8, 2023
e446399
Remove assertNode params
jakebailey Jan 8, 2023
a0199a3
Attempt to revert some changes in deprecatedcompat
jakebailey Jan 8, 2023
5e01002
Merge branch 'main' into enable-strict-function-types
jakebailey Jan 9, 2023
41cb1fc
For now, just fully specify all every/some in this file
jakebailey Jan 10, 2023
ae4be6b
Fix typo
jakebailey Jan 10, 2023
bfb1417
Merge branch 'main' into enable-strict-function-types
jakebailey Jan 11, 2023
00261cb
Revert some explicit type parameters fixed by inference tweak PRs in …
jakebailey Jan 11, 2023
268670f
Merge branch 'main' into enable-strict-function-types
jakebailey Jan 11, 2023
129a69e
Merge branch 'main' into enable-strict-function-types
jakebailey Jan 13, 2023
837c3d5
Make visitor required in API
jakebailey Jan 13, 2023
4ff34cb
meh, just remove the check, it's easy to re-add if someone crashes
jakebailey Jan 13, 2023
292413f
Merge branch 'main' into enable-strict-function-types
jakebailey Jan 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ function convertToReusableCompilerOptionValue(option: CommandLineOption | undefi
if (option) {
Debug.assert(option.type !== "listOrElement");
if (option.type === "list") {
const values = value as readonly (string | number)[];
const values = value as readonly string[];
if (option.element.isFilePath && values.length) {
return values.map(relativeToBuildInfo);
}
Expand Down
79 changes: 42 additions & 37 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2878,7 +2878,7 @@ export function convertToOptionsWithAbsolutePaths(options: CompilerOptions, toAb
function convertToOptionValueWithAbsolutePaths(option: CommandLineOption | undefined, value: CompilerOptionsValue, toAbsolutePath: (path: string) => string) {
if (option && !isNullOrUndefined(value)) {
if (option.type === "list") {
const values = value as readonly (string | number)[];
const values = value as readonly string[];
if (option.element.isFilePath && values.length) {
return values.map(toAbsolutePath);
}
Expand Down Expand Up @@ -3839,7 +3839,8 @@ function validateSpecs(specs: readonly string[], errors: Push<Diagnostic>, disal
}
}

function specToDiagnostic(spec: string, disallowTrailingRecursion?: boolean): [DiagnosticMessage, string] | undefined {
function specToDiagnostic(spec: CompilerOptionsValue, disallowTrailingRecursion?: boolean): [DiagnosticMessage, string] | undefined {
Debug.assert(typeof spec === "string");
if (disallowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) {
return [Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec];
}
Expand Down
40 changes: 25 additions & 15 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ export function intersperse<T>(input: T[], element: T): T[] {
*
* @internal
*/
export function every<T, U extends T>(array: readonly T[], callback: (element: T, index: number) => element is U): array is readonly U[];
/** @internal */
export function every<T, U extends T>(array: readonly T[] | undefined, callback: (element: T, index: number) => element is U): array is readonly U[] | undefined;
/** @internal */
export function every<T>(array: readonly T[] | undefined, callback: (element: T, index: number) => boolean): boolean;
export function every<T>(array: readonly T[] | undefined, callback: (element: T, index: number) => boolean): boolean {
if (array) {
for (let i = 0; i < array.length; i++) {
Expand Down Expand Up @@ -478,7 +483,7 @@ export function sameFlatMap<T>(array: T[], mapfn: (x: T, i: number) => T | reado
/** @internal */
export function sameFlatMap<T>(array: readonly T[], mapfn: (x: T, i: number) => T | readonly T[]): readonly T[];
/** @internal */
export function sameFlatMap<T>(array: T[], mapfn: (x: T, i: number) => T | T[]): T[] {
export function sameFlatMap<T>(array: readonly T[], mapfn: (x: T, i: number) => T | readonly T[]): readonly T[] {
let result: T[] | undefined;
if (array) {
for (let i = 0; i < array.length; i++) {
Expand Down Expand Up @@ -703,11 +708,19 @@ export function concatenate<T>(array1: T[], array2: T[]): T[];
/** @internal */
export function concatenate<T>(array1: readonly T[], array2: readonly T[]): readonly T[];
/** @internal */
export function concatenate<T>(array1: T[] | undefined, array2: T[] | undefined): T[];
export function concatenate<T>(array1: T[], array2: T[] | undefined): T[]; // eslint-disable-line @typescript-eslint/unified-signatures
/** @internal */
export function concatenate<T>(array1: T[] | undefined, array2: T[]): T[]; // eslint-disable-line @typescript-eslint/unified-signatures
/** @internal */
export function concatenate<T>(array1: readonly T[], array2: readonly T[] | undefined): readonly T[]; // eslint-disable-line @typescript-eslint/unified-signatures
/** @internal */
export function concatenate<T>(array1: readonly T[] | undefined, array2: readonly T[]): readonly T[]; // eslint-disable-line @typescript-eslint/unified-signatures
/** @internal */
export function concatenate<T>(array1: readonly T[] | undefined, array2: readonly T[] | undefined): readonly T[];
export function concatenate<T>(array1: T[] | undefined, array2: T[] | undefined): T[] | undefined;
/** @internal */
export function concatenate<T>(array1: T[], array2: T[]): T[] {
export function concatenate<T>(array1: readonly T[] | undefined, array2: readonly T[] | undefined): readonly T[] | undefined;
/** @internal */
export function concatenate<T>(array1: readonly T[] | undefined, array2: readonly T[] | undefined): readonly T[] | undefined {
if (!some(array2)) return array1;
if (!some(array1)) return array2;
return [...array1, ...array2];
Expand Down Expand Up @@ -856,7 +869,7 @@ export function detectSortCaseSensitivity(array: readonly string[], useEslintOrd
/** @internal */
export function detectSortCaseSensitivity<T>(array: readonly T[], useEslintOrdering: boolean, getString: (element: T) => string): SortKind;
/** @internal */
export function detectSortCaseSensitivity<T>(array: readonly T[], useEslintOrdering: boolean, getString?: (element: T) => string): SortKind {
export function detectSortCaseSensitivity<T>(array: readonly T[], useEslintOrdering?: boolean, getString?: (element: T) => string): SortKind {
let kind = SortKind.Both;
if (array.length < 2) return kind;
const caseSensitiveComparer = getString
Expand Down Expand Up @@ -915,7 +928,7 @@ export function compact<T>(array: T[]): T[]; // eslint-disable-line @typescript-
/** @internal */
export function compact<T>(array: readonly T[]): readonly T[]; // eslint-disable-line @typescript-eslint/unified-signatures
/** @internal */
export function compact<T>(array: T[]): T[] {
export function compact<T>(array: readonly T[]): readonly T[] {
let result: T[] | undefined;
if (array) {
for (let i = 0; i < array.length; i++) {
Expand Down Expand Up @@ -998,11 +1011,12 @@ export function append<T>(to: T[] | undefined, value: T | undefined): T[] | unde
/** @internal */
export function append<T>(to: Push<T>, value: T | undefined): void;
/** @internal */
export function append<T>(to: T[], value: T | undefined): T[] | undefined {
if (value === undefined) return to;
export function append<T>(to: Push<T> | T[] | undefined, value: T | undefined): T[] | undefined {
// If to is Push<T>, return value is void, so safe to cast to T[].
if (value === undefined) return to as T[];
if (to === undefined) return [value];
to.push(value);
return to;
return to as T[];
}

/**
Expand Down Expand Up @@ -1315,7 +1329,7 @@ export function reduceLeft<T, U>(array: readonly T[] | undefined, f: (memo: U, v
/** @internal */
export function reduceLeft<T>(array: readonly T[], f: (memo: T, value: T, i: number) => T): T | undefined;
/** @internal */
export function reduceLeft<T>(array: T[], f: (memo: T, value: T, i: number) => T, initial?: T, start?: number, count?: number): T | undefined {
export function reduceLeft<T>(array: readonly T[] | undefined, f: (memo: T, value: T, i: number) => T, initial?: T, start?: number, count?: number): T | undefined {
if (array && array.length > 0) {
const size = array.length;
if (size > 0) {
Expand Down Expand Up @@ -1867,11 +1881,7 @@ export function isNumber(x: unknown): x is number {
}

/** @internal */
export function tryCast<TOut extends TIn, TIn = any>(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined;
/** @internal */
export function tryCast<T>(value: T, test: (value: T) => boolean): T | undefined;
/** @internal */
export function tryCast<T>(value: T, test: (value: T) => boolean): T | undefined {
export function tryCast<TOut extends TIn, TIn = any>(value: TIn | undefined, test: (value: TIn) => value is TOut): TOut | undefined {
return value !== undefined && test(value) ? value : undefined;
}

Expand Down
6 changes: 3 additions & 3 deletions src/compiler/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,13 @@ export namespace Debug {
export function assertEachNode<T extends Node, U extends T>(nodes: readonly T[], test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is readonly U[];
export function assertEachNode<T extends Node, U extends T>(nodes: NodeArray<T> | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is NodeArray<U> | undefined;
export function assertEachNode<T extends Node, U extends T>(nodes: readonly T[] | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is readonly U[] | undefined;
export function assertEachNode(nodes: readonly Node[], test: (node: Node) => boolean, message?: string, stackCrawlMark?: AnyFunction): void;
export function assertEachNode(nodes: readonly Node[] | undefined, test: (node: Node) => boolean, message?: string, stackCrawlMark?: AnyFunction) {
export function assertEachNode(nodes: readonly Node[], test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction): void;
export function assertEachNode(nodes: readonly Node[] | undefined, test: ((node: Node) => boolean) | undefined, message?: string, stackCrawlMark?: AnyFunction) {
if (shouldAssertFunction(AssertionLevel.Normal, "assertEachNode")) {
assert(
test === undefined || every(nodes, test),
message || "Unexpected node.",
() => `Node array did not pass test '${getFunctionName(test)}'.`,
() => `Node array did not pass test '${getFunctionName(test!)}'.`,
stackCrawlMark || assertEachNode);
}
}
Expand Down
Loading