-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't try to add an implicit undefined for mapped properties outside …
…of `strictNullChecks` (#60393)
- Loading branch information
Showing
17 changed files
with
721 additions
and
1 deletion.
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
48 changes: 48 additions & 0 deletions
48
tests/baselines/reference/declarationEmitOptionalMappedTypePropertyNoStrictNullChecks1.js
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,48 @@ | ||
//// [tests/cases/compiler/declarationEmitOptionalMappedTypePropertyNoStrictNullChecks1.ts] //// | ||
|
||
//// [createApi.ts] | ||
type Id<T> = { | ||
[K in keyof T]: T[K]; | ||
} & {}; | ||
|
||
export declare function createApi<Definitions>(_: { endpoints: Definitions }): { | ||
[K in keyof Definitions as `use${Capitalize<K & string>}Query`]: () => Id<{ | ||
status: "uninitialized"; | ||
originalArgs?: undefined; | ||
}>; | ||
}; | ||
//// [index.ts] | ||
import { createApi } from "./createApi"; | ||
const slice = createApi({ | ||
endpoints: { | ||
test: { | ||
url: `/user`, | ||
}, | ||
}, | ||
}); | ||
export const { useTestQuery } = slice; | ||
//// [createApi.d.ts] | ||
type Id<T> = { | ||
[K in keyof T]: T[K]; | ||
} & {}; | ||
export declare function createApi<Definitions>(_: { | ||
endpoints: Definitions; | ||
}): { | ||
[K in keyof Definitions as `use${Capitalize<K & string>}Query`]: () => Id<{ | ||
status: "uninitialized"; | ||
originalArgs?: undefined; | ||
}>; | ||
}; | ||
export {}; | ||
//// [index.d.ts] | ||
export declare const useTestQuery: () => { | ||
status: "uninitialized"; | ||
originalArgs?: undefined; | ||
}; |
63 changes: 63 additions & 0 deletions
63
.../baselines/reference/declarationEmitOptionalMappedTypePropertyNoStrictNullChecks1.symbols
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,63 @@ | ||
//// [tests/cases/compiler/declarationEmitOptionalMappedTypePropertyNoStrictNullChecks1.ts] //// | ||
|
||
=== createApi.ts === | ||
type Id<T> = { | ||
>Id : Symbol(Id, Decl(createApi.ts, 0, 0)) | ||
>T : Symbol(T, Decl(createApi.ts, 0, 8)) | ||
|
||
[K in keyof T]: T[K]; | ||
>K : Symbol(K, Decl(createApi.ts, 1, 3)) | ||
>T : Symbol(T, Decl(createApi.ts, 0, 8)) | ||
>T : Symbol(T, Decl(createApi.ts, 0, 8)) | ||
>K : Symbol(K, Decl(createApi.ts, 1, 3)) | ||
|
||
} & {}; | ||
|
||
export declare function createApi<Definitions>(_: { endpoints: Definitions }): { | ||
>createApi : Symbol(createApi, Decl(createApi.ts, 2, 7)) | ||
>Definitions : Symbol(Definitions, Decl(createApi.ts, 4, 34)) | ||
>_ : Symbol(_, Decl(createApi.ts, 4, 47)) | ||
>endpoints : Symbol(endpoints, Decl(createApi.ts, 4, 51)) | ||
>Definitions : Symbol(Definitions, Decl(createApi.ts, 4, 34)) | ||
|
||
[K in keyof Definitions as `use${Capitalize<K & string>}Query`]: () => Id<{ | ||
>K : Symbol(K, Decl(createApi.ts, 5, 3)) | ||
>Definitions : Symbol(Definitions, Decl(createApi.ts, 4, 34)) | ||
>Capitalize : Symbol(Capitalize, Decl(lib.es5.d.ts, --, --)) | ||
>K : Symbol(K, Decl(createApi.ts, 5, 3)) | ||
>Id : Symbol(Id, Decl(createApi.ts, 0, 0)) | ||
|
||
status: "uninitialized"; | ||
>status : Symbol(status, Decl(createApi.ts, 5, 77)) | ||
|
||
originalArgs?: undefined; | ||
>originalArgs : Symbol(originalArgs, Decl(createApi.ts, 6, 28)) | ||
|
||
}>; | ||
}; | ||
|
||
=== index.ts === | ||
import { createApi } from "./createApi"; | ||
>createApi : Symbol(createApi, Decl(index.ts, 0, 8)) | ||
|
||
const slice = createApi({ | ||
>slice : Symbol(slice, Decl(index.ts, 2, 5)) | ||
>createApi : Symbol(createApi, Decl(index.ts, 0, 8)) | ||
|
||
endpoints: { | ||
>endpoints : Symbol(endpoints, Decl(index.ts, 2, 25)) | ||
|
||
test: { | ||
>test : Symbol(test, Decl(index.ts, 3, 14)) | ||
|
||
url: `/user`, | ||
>url : Symbol(url, Decl(index.ts, 4, 11)) | ||
|
||
}, | ||
}, | ||
}); | ||
|
||
export const { useTestQuery } = slice; | ||
>useTestQuery : Symbol(useTestQuery, Decl(index.ts, 10, 14)) | ||
>slice : Symbol(slice, Decl(index.ts, 2, 5)) | ||
|
73 changes: 73 additions & 0 deletions
73
tests/baselines/reference/declarationEmitOptionalMappedTypePropertyNoStrictNullChecks1.types
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,73 @@ | ||
//// [tests/cases/compiler/declarationEmitOptionalMappedTypePropertyNoStrictNullChecks1.ts] //// | ||
|
||
=== createApi.ts === | ||
type Id<T> = { | ||
>Id : { [K in keyof T]: T[K]; } | ||
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
[K in keyof T]: T[K]; | ||
} & {}; | ||
|
||
export declare function createApi<Definitions>(_: { endpoints: Definitions }): { | ||
>createApi : <Definitions>(_: { endpoints: Definitions; }) => { [K in keyof Definitions as `use${Capitalize<K & string>}Query`]: () => Id<{ status: "uninitialized"; originalArgs?: undefined; }>; } | ||
> : ^ ^^ ^^ ^^^^^ | ||
>_ : { endpoints: Definitions; } | ||
> : ^^^^^^^^^^^^^ ^^^ | ||
>endpoints : Definitions | ||
> : ^^^^^^^^^^^ | ||
|
||
[K in keyof Definitions as `use${Capitalize<K & string>}Query`]: () => Id<{ | ||
status: "uninitialized"; | ||
>status : "uninitialized" | ||
> : ^^^^^^^^^^^^^^^ | ||
|
||
originalArgs?: undefined; | ||
>originalArgs : undefined | ||
> : ^^^^^^^^^ | ||
|
||
}>; | ||
}; | ||
|
||
=== index.ts === | ||
import { createApi } from "./createApi"; | ||
>createApi : <Definitions>(_: { endpoints: Definitions; }) => { [K in keyof Definitions as `use${Capitalize<K & string>}Query`]: () => { status: "uninitialized"; originalArgs?: undefined; }; } | ||
> : ^ ^^ ^^ ^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^ | ||
|
||
const slice = createApi({ | ||
>slice : { useTestQuery: () => { status: "uninitialized"; originalArgs?: undefined; }; } | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^ | ||
>createApi({ endpoints: { test: { url: `/user`, }, },}) : { useTestQuery: () => { status: "uninitialized"; originalArgs?: undefined; }; } | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^ | ||
>createApi : <Definitions>(_: { endpoints: Definitions; }) => { [K in keyof Definitions as `use${Capitalize<K & string>}Query`]: () => { status: "uninitialized"; originalArgs?: undefined; }; } | ||
> : ^ ^^ ^^ ^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^ | ||
>{ endpoints: { test: { url: `/user`, }, },} : { endpoints: { test: { url: string; }; }; } | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
endpoints: { | ||
>endpoints : { test: { url: string; }; } | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>{ test: { url: `/user`, }, } : { test: { url: string; }; } | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
test: { | ||
>test : { url: string; } | ||
> : ^^^^^^^^^^^^^^^^ | ||
>{ url: `/user`, } : { url: string; } | ||
> : ^^^^^^^^^^^^^^^^ | ||
|
||
url: `/user`, | ||
>url : string | ||
> : ^^^^^^ | ||
>`/user` : "/user" | ||
> : ^^^^^^^ | ||
|
||
}, | ||
}, | ||
}); | ||
|
||
export const { useTestQuery } = slice; | ||
>useTestQuery : () => { status: "uninitialized"; originalArgs?: undefined; } | ||
> : ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^ | ||
>slice : { useTestQuery: () => { status: "uninitialized"; originalArgs?: undefined; }; } | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^ | ||
|
48 changes: 48 additions & 0 deletions
48
tests/baselines/reference/declarationEmitOptionalMappedTypePropertyNoStrictNullChecks2.js
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,48 @@ | ||
//// [tests/cases/compiler/declarationEmitOptionalMappedTypePropertyNoStrictNullChecks2.ts] //// | ||
|
||
//// [createApi.ts] | ||
type Id<T> = { | ||
[K in keyof T]: T[K]; | ||
} & {}; | ||
|
||
export declare function createApi<Definitions>(_: { endpoints: Definitions }): { | ||
[K in keyof Definitions as `use${Capitalize<K & string>}Query`]: () => Id<{ | ||
status: "uninitialized"; | ||
originalArgs?: any[]; | ||
}>; | ||
}; | ||
//// [index.ts] | ||
import { createApi } from "./createApi"; | ||
const slice = createApi({ | ||
endpoints: { | ||
test: { | ||
url: `/user`, | ||
}, | ||
}, | ||
}); | ||
export const { useTestQuery } = slice; | ||
//// [createApi.d.ts] | ||
type Id<T> = { | ||
[K in keyof T]: T[K]; | ||
} & {}; | ||
export declare function createApi<Definitions>(_: { | ||
endpoints: Definitions; | ||
}): { | ||
[K in keyof Definitions as `use${Capitalize<K & string>}Query`]: () => Id<{ | ||
status: "uninitialized"; | ||
originalArgs?: any[]; | ||
}>; | ||
}; | ||
export {}; | ||
//// [index.d.ts] | ||
export declare const useTestQuery: () => { | ||
status: "uninitialized"; | ||
originalArgs?: any[]; | ||
}; |
63 changes: 63 additions & 0 deletions
63
.../baselines/reference/declarationEmitOptionalMappedTypePropertyNoStrictNullChecks2.symbols
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,63 @@ | ||
//// [tests/cases/compiler/declarationEmitOptionalMappedTypePropertyNoStrictNullChecks2.ts] //// | ||
|
||
=== createApi.ts === | ||
type Id<T> = { | ||
>Id : Symbol(Id, Decl(createApi.ts, 0, 0)) | ||
>T : Symbol(T, Decl(createApi.ts, 0, 8)) | ||
|
||
[K in keyof T]: T[K]; | ||
>K : Symbol(K, Decl(createApi.ts, 1, 3)) | ||
>T : Symbol(T, Decl(createApi.ts, 0, 8)) | ||
>T : Symbol(T, Decl(createApi.ts, 0, 8)) | ||
>K : Symbol(K, Decl(createApi.ts, 1, 3)) | ||
|
||
} & {}; | ||
|
||
export declare function createApi<Definitions>(_: { endpoints: Definitions }): { | ||
>createApi : Symbol(createApi, Decl(createApi.ts, 2, 7)) | ||
>Definitions : Symbol(Definitions, Decl(createApi.ts, 4, 34)) | ||
>_ : Symbol(_, Decl(createApi.ts, 4, 47)) | ||
>endpoints : Symbol(endpoints, Decl(createApi.ts, 4, 51)) | ||
>Definitions : Symbol(Definitions, Decl(createApi.ts, 4, 34)) | ||
|
||
[K in keyof Definitions as `use${Capitalize<K & string>}Query`]: () => Id<{ | ||
>K : Symbol(K, Decl(createApi.ts, 5, 3)) | ||
>Definitions : Symbol(Definitions, Decl(createApi.ts, 4, 34)) | ||
>Capitalize : Symbol(Capitalize, Decl(lib.es5.d.ts, --, --)) | ||
>K : Symbol(K, Decl(createApi.ts, 5, 3)) | ||
>Id : Symbol(Id, Decl(createApi.ts, 0, 0)) | ||
|
||
status: "uninitialized"; | ||
>status : Symbol(status, Decl(createApi.ts, 5, 77)) | ||
|
||
originalArgs?: any[]; | ||
>originalArgs : Symbol(originalArgs, Decl(createApi.ts, 6, 28)) | ||
|
||
}>; | ||
}; | ||
|
||
=== index.ts === | ||
import { createApi } from "./createApi"; | ||
>createApi : Symbol(createApi, Decl(index.ts, 0, 8)) | ||
|
||
const slice = createApi({ | ||
>slice : Symbol(slice, Decl(index.ts, 2, 5)) | ||
>createApi : Symbol(createApi, Decl(index.ts, 0, 8)) | ||
|
||
endpoints: { | ||
>endpoints : Symbol(endpoints, Decl(index.ts, 2, 25)) | ||
|
||
test: { | ||
>test : Symbol(test, Decl(index.ts, 3, 14)) | ||
|
||
url: `/user`, | ||
>url : Symbol(url, Decl(index.ts, 4, 11)) | ||
|
||
}, | ||
}, | ||
}); | ||
|
||
export const { useTestQuery } = slice; | ||
>useTestQuery : Symbol(useTestQuery, Decl(index.ts, 10, 14)) | ||
>slice : Symbol(slice, Decl(index.ts, 2, 5)) | ||
|
73 changes: 73 additions & 0 deletions
73
tests/baselines/reference/declarationEmitOptionalMappedTypePropertyNoStrictNullChecks2.types
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,73 @@ | ||
//// [tests/cases/compiler/declarationEmitOptionalMappedTypePropertyNoStrictNullChecks2.ts] //// | ||
|
||
=== createApi.ts === | ||
type Id<T> = { | ||
>Id : { [K in keyof T]: T[K]; } | ||
> : ^^^ ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
[K in keyof T]: T[K]; | ||
} & {}; | ||
|
||
export declare function createApi<Definitions>(_: { endpoints: Definitions }): { | ||
>createApi : <Definitions>(_: { endpoints: Definitions; }) => { [K in keyof Definitions as `use${Capitalize<K & string>}Query`]: () => Id<{ status: "uninitialized"; originalArgs?: any[]; }>; } | ||
> : ^ ^^ ^^ ^^^^^ | ||
>_ : { endpoints: Definitions; } | ||
> : ^^^^^^^^^^^^^ ^^^ | ||
>endpoints : Definitions | ||
> : ^^^^^^^^^^^ | ||
|
||
[K in keyof Definitions as `use${Capitalize<K & string>}Query`]: () => Id<{ | ||
status: "uninitialized"; | ||
>status : "uninitialized" | ||
> : ^^^^^^^^^^^^^^^ | ||
|
||
originalArgs?: any[]; | ||
>originalArgs : any[] | ||
> : ^^^^^ | ||
|
||
}>; | ||
}; | ||
|
||
=== index.ts === | ||
import { createApi } from "./createApi"; | ||
>createApi : <Definitions>(_: { endpoints: Definitions; }) => { [K in keyof Definitions as `use${Capitalize<K & string>}Query`]: () => { status: "uninitialized"; originalArgs?: any[]; }; } | ||
> : ^ ^^ ^^ ^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^ | ||
|
||
const slice = createApi({ | ||
>slice : { useTestQuery: () => { status: "uninitialized"; originalArgs?: any[]; }; } | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^ | ||
>createApi({ endpoints: { test: { url: `/user`, }, },}) : { useTestQuery: () => { status: "uninitialized"; originalArgs?: any[]; }; } | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^ | ||
>createApi : <Definitions>(_: { endpoints: Definitions; }) => { [K in keyof Definitions as `use${Capitalize<K & string>}Query`]: () => { status: "uninitialized"; originalArgs?: any[]; }; } | ||
> : ^ ^^ ^^ ^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^ | ||
>{ endpoints: { test: { url: `/user`, }, },} : { endpoints: { test: { url: string; }; }; } | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
endpoints: { | ||
>endpoints : { test: { url: string; }; } | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
>{ test: { url: `/user`, }, } : { test: { url: string; }; } | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
test: { | ||
>test : { url: string; } | ||
> : ^^^^^^^^^^^^^^^^ | ||
>{ url: `/user`, } : { url: string; } | ||
> : ^^^^^^^^^^^^^^^^ | ||
|
||
url: `/user`, | ||
>url : string | ||
> : ^^^^^^ | ||
>`/user` : "/user" | ||
> : ^^^^^^^ | ||
|
||
}, | ||
}, | ||
}); | ||
|
||
export const { useTestQuery } = slice; | ||
>useTestQuery : () => { status: "uninitialized"; originalArgs?: any[]; } | ||
> : ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^ | ||
>slice : { useTestQuery: () => { status: "uninitialized"; originalArgs?: any[]; }; } | ||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^ | ||
|
Oops, something went wrong.