diff --git a/tsc/internal/execute/tsctests/tsc_test.go b/tsc/internal/execute/tsctests/tsc_test.go index aff5f93620582..c5f7c8c43d779 100644 --- a/tsc/internal/execute/tsctests/tsc_test.go +++ b/tsc/internal/execute/tsctests/tsc_test.go @@ -282,6 +282,43 @@ func TestTscCommandline(t *testing.T) { }, } + for _, value := range []string{"false", "true", "omitted"} { + option := "" + if value != "omitted" { + option = `, "alwaysStrict": ` + value + } + testCases = append(testCases, &tscInput{ + subScenario: "alwaysStrict " + value + " in configuration", + files: FileMap{ + "/home/src/workspaces/project/tsconfig.json": fmt.Sprintf(`{"compilerOptions": {"target": "es2015"%s}}`, option), + "/home/src/workspaces/project/index.ts": "export {};", + }, + commandLineArgs: []string{"--noEmit"}, + }) + } + for _, setting := range []struct { + name string + config string + base string + }{ + {"relative", `{"compilerOptions": {"target": "es2015", "baseUrl": "."}}`, ""}, + {"empty", `{"compilerOptions": {"target": "es2015", "baseUrl": ""}}`, ""}, + {"inherited", `{"extends": "./base.json"}`, `{"compilerOptions": {"target": "es2015", "baseUrl": "."}}`}, + {"omitted", `{"compilerOptions": {"target": "es2015"}}`, ""}, + } { + files := FileMap{ + "/home/src/workspaces/project/tsconfig.json": setting.config, + "/home/src/workspaces/project/index.ts": "export {};", + } + if setting.base != "" { + files["/home/src/workspaces/project/base.json"] = setting.base + } + testCases = append(testCases, &tscInput{ + subScenario: "baseUrl " + setting.name + " in configuration", + files: files, + commandLineArgs: []string{"--noEmit"}, + }) + } for _, testCase := range testCases { testCase.run(t, "commandLine") } diff --git a/tsc/testdata/baselines/reference/compiler/assertedGenericPartialIndexedAssignment.symbols b/tsc/testdata/baselines/reference/compiler/assertedGenericPartialIndexedAssignment.symbols new file mode 100644 index 0000000000000..5cb9272d772b8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/assertedGenericPartialIndexedAssignment.symbols @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/assertedGenericPartialIndexedAssignment.ts] //// + +=== assertedGenericPartialIndexedAssignment.ts === +function write>(values: Partial, key: string) { +>write : Symbol(write, Decl(assertedGenericPartialIndexedAssignment.ts, 0, 0)) +>T : Symbol(T, Decl(assertedGenericPartialIndexedAssignment.ts, 0, 15)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>values : Symbol(values, Decl(assertedGenericPartialIndexedAssignment.ts, 0, 50)) +>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(assertedGenericPartialIndexedAssignment.ts, 0, 15)) +>key : Symbol(key, Decl(assertedGenericPartialIndexedAssignment.ts, 0, 69)) + + (values[key] as unknown) = 0; +>values : Symbol(values, Decl(assertedGenericPartialIndexedAssignment.ts, 0, 50)) +>key : Symbol(key, Decl(assertedGenericPartialIndexedAssignment.ts, 0, 69)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/assertedGenericPartialIndexedAssignment.types b/tsc/testdata/baselines/reference/compiler/assertedGenericPartialIndexedAssignment.types new file mode 100644 index 0000000000000..3b7fa53bf9f44 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/assertedGenericPartialIndexedAssignment.types @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/assertedGenericPartialIndexedAssignment.ts] //// + +=== assertedGenericPartialIndexedAssignment.ts === +function write>(values: Partial, key: string) { +>write : >(values: Partial, key: string) => void +>values : Partial +>key : string + + (values[key] as unknown) = 0; +>(values[key] as unknown) = 0 : 0 +>(values[key] as unknown) : unknown +>values[key] as unknown : unknown +>values[key] : T[string] | undefined +>values : Partial +>key : string +>0 : 0 +} + diff --git a/tsc/testdata/baselines/reference/compiler/assertedReadonlyParameterPropertyAssignment.symbols b/tsc/testdata/baselines/reference/compiler/assertedReadonlyParameterPropertyAssignment.symbols new file mode 100644 index 0000000000000..cd414f19466f8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/assertedReadonlyParameterPropertyAssignment.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/assertedReadonlyParameterPropertyAssignment.ts] //// + +=== assertedReadonlyParameterPropertyAssignment.ts === +class ReadonlyState { +>ReadonlyState : Symbol(ReadonlyState, Decl(assertedReadonlyParameterPropertyAssignment.ts, 0, 0)) + + constructor(readonly value: object) {} +>value : Symbol(ReadonlyState.value, Decl(assertedReadonlyParameterPropertyAssignment.ts, 1, 16)) + + clear() { +>clear : Symbol(ReadonlyState.clear, Decl(assertedReadonlyParameterPropertyAssignment.ts, 1, 42)) + + (this.value as unknown) = null; +>this.value : Symbol(ReadonlyState.value, Decl(assertedReadonlyParameterPropertyAssignment.ts, 1, 16)) +>this : Symbol(ReadonlyState, Decl(assertedReadonlyParameterPropertyAssignment.ts, 0, 0)) +>value : Symbol(ReadonlyState.value, Decl(assertedReadonlyParameterPropertyAssignment.ts, 1, 16)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/assertedReadonlyParameterPropertyAssignment.types b/tsc/testdata/baselines/reference/compiler/assertedReadonlyParameterPropertyAssignment.types new file mode 100644 index 0000000000000..dbd17a6389a60 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/assertedReadonlyParameterPropertyAssignment.types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/assertedReadonlyParameterPropertyAssignment.ts] //// + +=== assertedReadonlyParameterPropertyAssignment.ts === +class ReadonlyState { +>ReadonlyState : ReadonlyState + + constructor(readonly value: object) {} +>value : object + + clear() { +>clear : () => void + + (this.value as unknown) = null; +>(this.value as unknown) = null : null +>(this.value as unknown) : unknown +>this.value as unknown : unknown +>this.value : object +>this : this +>value : object + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/callableConstructorUnionMetadata.symbols b/tsc/testdata/baselines/reference/compiler/callableConstructorUnionMetadata.symbols new file mode 100644 index 0000000000000..b5947d185c8a7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/callableConstructorUnionMetadata.symbols @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/callableConstructorUnionMetadata.ts] //// + +=== callableConstructorUnionMetadata.ts === +type Component = ((props: Props) => number) | (new (props: Props) => object); +>Component : Symbol(Component, Decl(callableConstructorUnionMetadata.ts, 0, 0)) +>Props : Symbol(Props, Decl(callableConstructorUnionMetadata.ts, 0, 15)) +>props : Symbol(props, Decl(callableConstructorUnionMetadata.ts, 0, 26)) +>Props : Symbol(Props, Decl(callableConstructorUnionMetadata.ts, 0, 15)) +>props : Symbol(props, Decl(callableConstructorUnionMetadata.ts, 0, 59)) +>Props : Symbol(Props, Decl(callableConstructorUnionMetadata.ts, 0, 15)) + +type Field = Component & { testIds?: {} }; +>Field : Symbol(Field, Decl(callableConstructorUnionMetadata.ts, 0, 84)) +>Props : Symbol(Props, Decl(callableConstructorUnionMetadata.ts, 1, 11)) +>Component : Symbol(Component, Decl(callableConstructorUnionMetadata.ts, 0, 0)) +>Props : Symbol(Props, Decl(callableConstructorUnionMetadata.ts, 1, 11)) +>testIds : Symbol(testIds, Decl(callableConstructorUnionMetadata.ts, 1, 40)) + +declare const component: (props: Props) => number; +>component : Symbol(component, Decl(callableConstructorUnionMetadata.ts, 3, 13)) +>Props : Symbol(Props, Decl(callableConstructorUnionMetadata.ts, 3, 26)) +>props : Symbol(props, Decl(callableConstructorUnionMetadata.ts, 3, 33)) +>Props : Symbol(Props, Decl(callableConstructorUnionMetadata.ts, 3, 26)) + +const field: Field = component; +>field : Symbol(field, Decl(callableConstructorUnionMetadata.ts, 4, 5)) +>Field : Symbol(Field, Decl(callableConstructorUnionMetadata.ts, 0, 84)) +>component : Symbol(component, Decl(callableConstructorUnionMetadata.ts, 3, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/callableConstructorUnionMetadata.types b/tsc/testdata/baselines/reference/compiler/callableConstructorUnionMetadata.types new file mode 100644 index 0000000000000..d9ea9c9fdabfa --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/callableConstructorUnionMetadata.types @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/callableConstructorUnionMetadata.ts] //// + +=== callableConstructorUnionMetadata.ts === +type Component = ((props: Props) => number) | (new (props: Props) => object); +>Component : Component +>props : Props +>props : Props + +type Field = Component & { testIds?: {} }; +>Field : Field +>testIds : {} | undefined + +declare const component: (props: Props) => number; +>component : (props: Props) => number +>props : Props + +const field: Field = component; +>field : Field +>component : (props: Props) => number + diff --git a/tsc/testdata/baselines/reference/compiler/callableWeakMetadata.symbols b/tsc/testdata/baselines/reference/compiler/callableWeakMetadata.symbols new file mode 100644 index 0000000000000..676de7eccdd88 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/callableWeakMetadata.symbols @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/callableWeakMetadata.ts] //// + +=== callableWeakMetadata.ts === +type Initializer = (() => number) & { mutators?: [] }; +>Initializer : Symbol(Initializer, Decl(callableWeakMetadata.ts, 0, 0)) +>mutators : Symbol(mutators, Decl(callableWeakMetadata.ts, 0, 37)) + +declare function createStore(initializer: Initializer): void; +>createStore : Symbol(createStore, Decl(callableWeakMetadata.ts, 0, 54)) +>initializer : Symbol(initializer, Decl(callableWeakMetadata.ts, 2, 29)) +>Initializer : Symbol(Initializer, Decl(callableWeakMetadata.ts, 0, 0)) + +createStore(() => 1); +>createStore : Symbol(createStore, Decl(callableWeakMetadata.ts, 0, 54)) + diff --git a/tsc/testdata/baselines/reference/compiler/callableWeakMetadata.types b/tsc/testdata/baselines/reference/compiler/callableWeakMetadata.types new file mode 100644 index 0000000000000..39c2bc5701b3a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/callableWeakMetadata.types @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/callableWeakMetadata.ts] //// + +=== callableWeakMetadata.ts === +type Initializer = (() => number) & { mutators?: [] }; +>Initializer : Initializer +>mutators : [] | undefined + +declare function createStore(initializer: Initializer): void; +>createStore : (initializer: Initializer) => void +>initializer : Initializer + +createStore(() => 1); +>createStore(() => 1) : void +>createStore : (initializer: Initializer) => void +>() => 1 : () => number +>1 : 1 + diff --git a/tsc/testdata/baselines/reference/compiler/callableWeakMetadataCallSuggestion.symbols b/tsc/testdata/baselines/reference/compiler/callableWeakMetadataCallSuggestion.symbols new file mode 100644 index 0000000000000..4c2aabe563a7a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/callableWeakMetadataCallSuggestion.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/callableWeakMetadataCallSuggestion.ts] //// + +=== callableWeakMetadataCallSuggestion.ts === +type Initializer = (() => number) & { mutators?: [] }; +>Initializer : Symbol(Initializer, Decl(callableWeakMetadataCallSuggestion.ts, 0, 0)) +>mutators : Symbol(mutators, Decl(callableWeakMetadataCallSuggestion.ts, 0, 37)) + +declare function createStore(initializer: Initializer): void; +>createStore : Symbol(createStore, Decl(callableWeakMetadataCallSuggestion.ts, 0, 54)) +>initializer : Symbol(initializer, Decl(callableWeakMetadataCallSuggestion.ts, 2, 29)) +>Initializer : Symbol(Initializer, Decl(callableWeakMetadataCallSuggestion.ts, 0, 0)) + +declare const initializer: () => any; +>initializer : Symbol(initializer, Decl(callableWeakMetadataCallSuggestion.ts, 3, 13)) + +createStore(initializer); +>createStore : Symbol(createStore, Decl(callableWeakMetadataCallSuggestion.ts, 0, 54)) +>initializer : Symbol(initializer, Decl(callableWeakMetadataCallSuggestion.ts, 3, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/callableWeakMetadataCallSuggestion.types b/tsc/testdata/baselines/reference/compiler/callableWeakMetadataCallSuggestion.types new file mode 100644 index 0000000000000..778f805bd956f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/callableWeakMetadataCallSuggestion.types @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/callableWeakMetadataCallSuggestion.ts] //// + +=== callableWeakMetadataCallSuggestion.ts === +type Initializer = (() => number) & { mutators?: [] }; +>Initializer : Initializer +>mutators : [] | undefined + +declare function createStore(initializer: Initializer): void; +>createStore : (initializer: Initializer) => void +>initializer : Initializer + +declare const initializer: () => any; +>initializer : () => any + +createStore(initializer); +>createStore(initializer) : void +>createStore : (initializer: Initializer) => void +>initializer : () => any + diff --git a/tsc/testdata/baselines/reference/compiler/callbackAssignedNonNull.symbols b/tsc/testdata/baselines/reference/compiler/callbackAssignedNonNull.symbols new file mode 100644 index 0000000000000..b517ff4b9f51e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/callbackAssignedNonNull.symbols @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/callbackAssignedNonNull.ts] //// + +=== callbackAssignedNonNull.ts === +declare function initialize(callback: (cancel: () => void) => void): void; +>initialize : Symbol(initialize, Decl(callbackAssignedNonNull.ts, 0, 0)) +>callback : Symbol(callback, Decl(callbackAssignedNonNull.ts, 0, 28)) +>cancel : Symbol(cancel, Decl(callbackAssignedNonNull.ts, 0, 39)) + +function start() { +>start : Symbol(start, Decl(callbackAssignedNonNull.ts, 0, 74)) + + let cancel; +>cancel : Symbol(cancel, Decl(callbackAssignedNonNull.ts, 3, 7)) + + initialize(value => { +>initialize : Symbol(initialize, Decl(callbackAssignedNonNull.ts, 0, 0)) +>value : Symbol(value, Decl(callbackAssignedNonNull.ts, 4, 15)) + + cancel = value; +>cancel : Symbol(cancel, Decl(callbackAssignedNonNull.ts, 3, 7)) +>value : Symbol(value, Decl(callbackAssignedNonNull.ts, 4, 15)) + + }); + cancel!(); +>cancel : Symbol(cancel, Decl(callbackAssignedNonNull.ts, 3, 7)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/callbackAssignedNonNull.types b/tsc/testdata/baselines/reference/compiler/callbackAssignedNonNull.types new file mode 100644 index 0000000000000..bc37613da44da --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/callbackAssignedNonNull.types @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/callbackAssignedNonNull.ts] //// + +=== callbackAssignedNonNull.ts === +declare function initialize(callback: (cancel: () => void) => void): void; +>initialize : (callback: (cancel: () => void) => void) => void +>callback : (cancel: () => void) => void +>cancel : () => void + +function start() { +>start : () => void + + let cancel; +>cancel : any + + initialize(value => { +>initialize(value => { cancel = value; }) : void +>initialize : (callback: (cancel: () => void) => void) => void +>value => { cancel = value; } : (value: () => void) => void +>value : () => void + + cancel = value; +>cancel = value : () => void +>cancel : any +>value : () => void + + }); + cancel!(); +>cancel!() : any +>cancel! : any +>cancel : any +} + diff --git a/tsc/testdata/baselines/reference/compiler/chainedFilterPredicateInference.js b/tsc/testdata/baselines/reference/compiler/chainedFilterPredicateInference.js new file mode 100644 index 0000000000000..b971af38d2f15 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/chainedFilterPredicateInference.js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/chainedFilterPredicateInference.ts] //// + +//// [chainedFilterPredicateInference.ts] +declare const items: { id: number }[]; +declare const registry: { [id: number]: { [frame: number]: unknown } }; + +items + .filter(item => true) + .filter(item => !registry[item.id]) + .forEach(item => item.id); + + +//// [chainedFilterPredicateInference.js] +"use strict"; +items + .filter(item => true) + .filter(item => !registry[item.id]) + .forEach(item => item.id); diff --git a/tsc/testdata/baselines/reference/compiler/chainedFilterPredicateInference.symbols b/tsc/testdata/baselines/reference/compiler/chainedFilterPredicateInference.symbols new file mode 100644 index 0000000000000..66e4d84e0aacb --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/chainedFilterPredicateInference.symbols @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/chainedFilterPredicateInference.ts] //// + +=== chainedFilterPredicateInference.ts === +declare const items: { id: number }[]; +>items : Symbol(items, Decl(chainedFilterPredicateInference.ts, 0, 13)) +>id : Symbol(id, Decl(chainedFilterPredicateInference.ts, 0, 22)) + +declare const registry: { [id: number]: { [frame: number]: unknown } }; +>registry : Symbol(registry, Decl(chainedFilterPredicateInference.ts, 1, 13)) +>id : Symbol(id, Decl(chainedFilterPredicateInference.ts, 1, 27)) +>frame : Symbol(frame, Decl(chainedFilterPredicateInference.ts, 1, 43)) + +items +>items .filter(item => true) .filter(item => !registry[item.id]) .forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>items .filter(item => true) .filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>items .filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>items : Symbol(items, Decl(chainedFilterPredicateInference.ts, 0, 13)) + + .filter(item => true) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>item : Symbol(item, Decl(chainedFilterPredicateInference.ts, 4, 12)) + + .filter(item => !registry[item.id]) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>item : Symbol(item, Decl(chainedFilterPredicateInference.ts, 5, 12)) +>registry : Symbol(registry, Decl(chainedFilterPredicateInference.ts, 1, 13)) +>item.id : Symbol(id, Decl(chainedFilterPredicateInference.ts, 0, 22)) +>item : Symbol(item, Decl(chainedFilterPredicateInference.ts, 5, 12)) +>id : Symbol(id, Decl(chainedFilterPredicateInference.ts, 0, 22)) + + .forEach(item => item.id); +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>item : Symbol(item, Decl(chainedFilterPredicateInference.ts, 6, 13)) +>item.id : Symbol(id, Decl(chainedFilterPredicateInference.ts, 0, 22)) +>item : Symbol(item, Decl(chainedFilterPredicateInference.ts, 6, 13)) +>id : Symbol(id, Decl(chainedFilterPredicateInference.ts, 0, 22)) + diff --git a/tsc/testdata/baselines/reference/compiler/chainedFilterPredicateInference.types b/tsc/testdata/baselines/reference/compiler/chainedFilterPredicateInference.types new file mode 100644 index 0000000000000..43a34fcadf8fa --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/chainedFilterPredicateInference.types @@ -0,0 +1,46 @@ +//// [tests/cases/compiler/chainedFilterPredicateInference.ts] //// + +=== chainedFilterPredicateInference.ts === +declare const items: { id: number }[]; +>items : { id: number; }[] +>id : number + +declare const registry: { [id: number]: { [frame: number]: unknown } }; +>registry : { [id: number]: { [frame: number]: unknown; }; } +>id : number +>frame : number + +items +>items .filter(item => true) .filter(item => !registry[item.id]) .forEach(item => item.id) : void +>items .filter(item => true) .filter(item => !registry[item.id]) .forEach : (callbackfn: (value: { id: number; }, index: number, array: { id: number; }[]) => void, thisArg?: any) => void +>items .filter(item => true) .filter(item => !registry[item.id]) : { id: number; }[] +>items .filter(item => true) .filter : { (predicate: (value: { id: number; }, index: number, array: { id: number; }[]) => value is S, thisArg?: any): S[]; (predicate: (value: { id: number; }, index: number, array: { id: number; }[]) => unknown, thisArg?: any): { id: number; }[]; } +>items .filter(item => true) : { id: number; }[] +>items .filter : { (predicate: (value: { id: number; }, index: number, array: { id: number; }[]) => value is S, thisArg?: any): S[]; (predicate: (value: { id: number; }, index: number, array: { id: number; }[]) => unknown, thisArg?: any): { id: number; }[]; } +>items : { id: number; }[] + + .filter(item => true) +>filter : { (predicate: (value: { id: number; }, index: number, array: { id: number; }[]) => value is S, thisArg?: any): S[]; (predicate: (value: { id: number; }, index: number, array: { id: number; }[]) => unknown, thisArg?: any): { id: number; }[]; } +>item => true : (item: { id: number; }) => true +>item : { id: number; } +>true : true + + .filter(item => !registry[item.id]) +>filter : { (predicate: (value: { id: number; }, index: number, array: { id: number; }[]) => value is S, thisArg?: any): S[]; (predicate: (value: { id: number; }, index: number, array: { id: number; }[]) => unknown, thisArg?: any): { id: number; }[]; } +>item => !registry[item.id] : (item: { id: number; }) => false +>item : { id: number; } +>!registry[item.id] : false +>registry[item.id] : { [frame: number]: unknown; } +>registry : { [id: number]: { [frame: number]: unknown; }; } +>item.id : number +>item : { id: number; } +>id : number + + .forEach(item => item.id); +>forEach : (callbackfn: (value: { id: number; }, index: number, array: { id: number; }[]) => void, thisArg?: any) => void +>item => item.id : (item: { id: number; }) => number +>item : { id: number; } +>item.id : number +>item : { id: number; } +>id : number + diff --git a/tsc/testdata/baselines/reference/compiler/componentEnhancerReturn.symbols b/tsc/testdata/baselines/reference/compiler/componentEnhancerReturn.symbols new file mode 100644 index 0000000000000..716d37578aebf --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/componentEnhancerReturn.symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/componentEnhancerReturn.ts] //// + +=== componentEnhancerReturn.ts === +type Component = ((props: number) => number) | (new (props: number) => object); +>Component : Symbol(Component, Decl(componentEnhancerReturn.ts, 0, 0)) +>props : Symbol(props, Decl(componentEnhancerReturn.ts, 0, 19)) +>props : Symbol(props, Decl(componentEnhancerReturn.ts, 0, 53)) + +type App = Component & { getInitialProps?: () => object }; +>App : Symbol(App, Decl(componentEnhancerReturn.ts, 0, 79)) +>Component : Symbol(Component, Decl(componentEnhancerReturn.ts, 0, 0)) +>getInitialProps : Symbol(getInitialProps, Decl(componentEnhancerReturn.ts, 1, 24)) + +declare function render(enhance: (app: App) => App): void; +>render : Symbol(render, Decl(componentEnhancerReturn.ts, 1, 58)) +>enhance : Symbol(enhance, Decl(componentEnhancerReturn.ts, 2, 24)) +>app : Symbol(app, Decl(componentEnhancerReturn.ts, 2, 34)) +>App : Symbol(App, Decl(componentEnhancerReturn.ts, 0, 79)) +>App : Symbol(App, Decl(componentEnhancerReturn.ts, 0, 79)) + +render(app => props => props); +>render : Symbol(render, Decl(componentEnhancerReturn.ts, 1, 58)) +>app : Symbol(app, Decl(componentEnhancerReturn.ts, 3, 7)) +>props : Symbol(props, Decl(componentEnhancerReturn.ts, 3, 13)) +>props : Symbol(props, Decl(componentEnhancerReturn.ts, 3, 13)) + +interface RenderPlugin { enhance(app: Component): (props: number) => number } +>RenderPlugin : Symbol(RenderPlugin, Decl(componentEnhancerReturn.ts, 3, 30)) +>enhance : Symbol(RenderPlugin.enhance, Decl(componentEnhancerReturn.ts, 5, 24)) +>app : Symbol(app, Decl(componentEnhancerReturn.ts, 5, 33)) +>Component : Symbol(Component, Decl(componentEnhancerReturn.ts, 0, 0)) +>props : Symbol(props, Decl(componentEnhancerReturn.ts, 5, 51)) + +declare const plugins: RenderPlugin[]; +>plugins : Symbol(plugins, Decl(componentEnhancerReturn.ts, 6, 13)) +>RenderPlugin : Symbol(RenderPlugin, Decl(componentEnhancerReturn.ts, 3, 30)) + +render(app => plugins.reduce((result, plugin) => plugin.enhance(result), app)); +>render : Symbol(render, Decl(componentEnhancerReturn.ts, 1, 58)) +>app : Symbol(app, Decl(componentEnhancerReturn.ts, 7, 7)) +>plugins.reduce : Symbol(Array.reduce, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>plugins : Symbol(plugins, Decl(componentEnhancerReturn.ts, 6, 13)) +>reduce : Symbol(Array.reduce, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>result : Symbol(result, Decl(componentEnhancerReturn.ts, 7, 30)) +>plugin : Symbol(plugin, Decl(componentEnhancerReturn.ts, 7, 37)) +>plugin.enhance : Symbol(RenderPlugin.enhance, Decl(componentEnhancerReturn.ts, 5, 24)) +>plugin : Symbol(plugin, Decl(componentEnhancerReturn.ts, 7, 37)) +>enhance : Symbol(RenderPlugin.enhance, Decl(componentEnhancerReturn.ts, 5, 24)) +>result : Symbol(result, Decl(componentEnhancerReturn.ts, 7, 30)) +>app : Symbol(app, Decl(componentEnhancerReturn.ts, 7, 7)) + diff --git a/tsc/testdata/baselines/reference/compiler/componentEnhancerReturn.types b/tsc/testdata/baselines/reference/compiler/componentEnhancerReturn.types new file mode 100644 index 0000000000000..a3049b18cb02c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/componentEnhancerReturn.types @@ -0,0 +1,53 @@ +//// [tests/cases/compiler/componentEnhancerReturn.ts] //// + +=== componentEnhancerReturn.ts === +type Component = ((props: number) => number) | (new (props: number) => object); +>Component : Component +>props : number +>props : number + +type App = Component & { getInitialProps?: () => object }; +>App : App +>getInitialProps : (() => object) | undefined + +declare function render(enhance: (app: App) => App): void; +>render : (enhance: (app: App) => App) => void +>enhance : (app: App) => App +>app : App + +render(app => props => props); +>render(app => props => props) : void +>render : (enhance: (app: App) => App) => void +>app => props => props : (app: App) => (props: number) => number +>app : App +>props => props : (props: number) => number +>props : number +>props : number + +interface RenderPlugin { enhance(app: Component): (props: number) => number } +>enhance : (app: Component) => (props: number) => number +>app : Component +>props : number + +declare const plugins: RenderPlugin[]; +>plugins : RenderPlugin[] + +render(app => plugins.reduce((result, plugin) => plugin.enhance(result), app)); +>render(app => plugins.reduce((result, plugin) => plugin.enhance(result), app)) : void +>render : (enhance: (app: App) => App) => void +>app => plugins.reduce((result, plugin) => plugin.enhance(result), app) : (app: App) => App +>app : App +>plugins.reduce((result, plugin) => plugin.enhance(result), app) : App +>plugins.reduce : { (callbackfn: (previousValue: RenderPlugin, currentValue: RenderPlugin, currentIndex: number, array: RenderPlugin[]) => RenderPlugin): RenderPlugin; (callbackfn: (previousValue: RenderPlugin, currentValue: RenderPlugin, currentIndex: number, array: RenderPlugin[]) => RenderPlugin, initialValue: RenderPlugin): RenderPlugin; (callbackfn: (previousValue: U, currentValue: RenderPlugin, currentIndex: number, array: RenderPlugin[]) => U, initialValue: U): U; } +>plugins : RenderPlugin[] +>reduce : { (callbackfn: (previousValue: RenderPlugin, currentValue: RenderPlugin, currentIndex: number, array: RenderPlugin[]) => RenderPlugin): RenderPlugin; (callbackfn: (previousValue: RenderPlugin, currentValue: RenderPlugin, currentIndex: number, array: RenderPlugin[]) => RenderPlugin, initialValue: RenderPlugin): RenderPlugin; (callbackfn: (previousValue: U, currentValue: RenderPlugin, currentIndex: number, array: RenderPlugin[]) => U, initialValue: U): U; } +>(result, plugin) => plugin.enhance(result) : (result: App, plugin: RenderPlugin) => (props: number) => number +>result : App +>plugin : RenderPlugin +>plugin.enhance(result) : (props: number) => number +>plugin.enhance : (app: Component) => (props: number) => number +>plugin : RenderPlugin +>enhance : (app: Component) => (props: number) => number +>result : App +>app : App + diff --git a/tsc/testdata/baselines/reference/compiler/compoundAssignmentAfterExcludedLiteral.js b/tsc/testdata/baselines/reference/compiler/compoundAssignmentAfterExcludedLiteral.js new file mode 100644 index 0000000000000..52c6f725d3381 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/compoundAssignmentAfterExcludedLiteral.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/compoundAssignmentAfterExcludedLiteral.ts] //// + +//// [compoundAssignmentAfterExcludedLiteral.ts] +function append(buffer: { value: string }) { + if (buffer.value !== "") { + buffer.value += "\n"; + } +} + + +//// [compoundAssignmentAfterExcludedLiteral.js] +"use strict"; +function append(buffer) { + if (buffer.value !== "") { + buffer.value += "\n"; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/compoundAssignmentAfterExcludedLiteral.symbols b/tsc/testdata/baselines/reference/compiler/compoundAssignmentAfterExcludedLiteral.symbols new file mode 100644 index 0000000000000..472f64a2a0e46 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/compoundAssignmentAfterExcludedLiteral.symbols @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/compoundAssignmentAfterExcludedLiteral.ts] //// + +=== compoundAssignmentAfterExcludedLiteral.ts === +function append(buffer: { value: string }) { +>append : Symbol(append, Decl(compoundAssignmentAfterExcludedLiteral.ts, 0, 0)) +>buffer : Symbol(buffer, Decl(compoundAssignmentAfterExcludedLiteral.ts, 0, 16)) +>value : Symbol(value, Decl(compoundAssignmentAfterExcludedLiteral.ts, 0, 25)) + + if (buffer.value !== "") { +>buffer.value : Symbol(value, Decl(compoundAssignmentAfterExcludedLiteral.ts, 0, 25)) +>buffer : Symbol(buffer, Decl(compoundAssignmentAfterExcludedLiteral.ts, 0, 16)) +>value : Symbol(value, Decl(compoundAssignmentAfterExcludedLiteral.ts, 0, 25)) + + buffer.value += "\n"; +>buffer.value : Symbol(value, Decl(compoundAssignmentAfterExcludedLiteral.ts, 0, 25)) +>buffer : Symbol(buffer, Decl(compoundAssignmentAfterExcludedLiteral.ts, 0, 16)) +>value : Symbol(value, Decl(compoundAssignmentAfterExcludedLiteral.ts, 0, 25)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/compoundAssignmentAfterExcludedLiteral.types b/tsc/testdata/baselines/reference/compiler/compoundAssignmentAfterExcludedLiteral.types new file mode 100644 index 0000000000000..438dc95ed9274 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/compoundAssignmentAfterExcludedLiteral.types @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/compoundAssignmentAfterExcludedLiteral.ts] //// + +=== compoundAssignmentAfterExcludedLiteral.ts === +function append(buffer: { value: string }) { +>append : (buffer: { value: string; }) => void +>buffer : { value: string; } +>value : string + + if (buffer.value !== "") { +>buffer.value !== "" : boolean +>buffer.value : string +>buffer : { value: string; } +>value : string +>"" : "" + + buffer.value += "\n"; +>buffer.value += "\n" : string +>buffer.value : string +>buffer : { value: string; } +>value : string +>"\n" : "\n" + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/conditionalExportsNodeTypesFallback.symbols b/tsc/testdata/baselines/reference/compiler/conditionalExportsNodeTypesFallback.symbols new file mode 100644 index 0000000000000..9d42e36f1fd29 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conditionalExportsNodeTypesFallback.symbols @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/conditionalExportsNodeTypesFallback.ts] //// + +=== /index.mts === +import { value } from "provider"; +>value : Symbol(value, Decl(index.mts, 0, 8)) + +value; +>value : Symbol(value, Decl(index.mts, 0, 8)) + +=== /node_modules/provider/types.d.ts === +export const value: number; +>value : Symbol(value, Decl(types.d.ts, 0, 12)) + diff --git a/tsc/testdata/baselines/reference/compiler/conditionalExportsNodeTypesFallback.trace.json b/tsc/testdata/baselines/reference/compiler/conditionalExportsNodeTypesFallback.trace.json new file mode 100644 index 0000000000000..3cbcade3af3db --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conditionalExportsNodeTypesFallback.trace.json @@ -0,0 +1,22 @@ +======== Resolving module 'provider' from '/index.mts'. ======== +Explicitly specified module resolution kind: 'NodeNext'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. +File '/package.json' does not exist. +Loading module 'provider' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. +Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Found 'package.json' at '/node_modules/provider/package.json'. +Entering conditional exports. +Matched 'exports' condition 'node'. +Using 'exports' subpath '.' with target './index.js'. +File name '/node_modules/provider/index.js' has a '.js' extension - stripping it. +File '/node_modules/provider/index.ts' does not exist. +File '/node_modules/provider/index.tsx' does not exist. +File '/node_modules/provider/index.d.ts' does not exist. +Failed to resolve under condition 'node'. +Matched 'exports' condition 'types'. +Using 'exports' subpath '.' with target './types.d.ts'. +File '/node_modules/provider/types.d.ts' exists - use it as a name resolution result. +Resolved under condition 'types'. +Exiting conditional exports. +Resolving real path for '/node_modules/provider/types.d.ts', result '/node_modules/provider/types.d.ts'. +======== Module name 'provider' was successfully resolved to '/node_modules/provider/types.d.ts'. ======== diff --git a/tsc/testdata/baselines/reference/compiler/conditionalExportsNodeTypesFallback.types b/tsc/testdata/baselines/reference/compiler/conditionalExportsNodeTypesFallback.types new file mode 100644 index 0000000000000..c692f2c478592 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conditionalExportsNodeTypesFallback.types @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/conditionalExportsNodeTypesFallback.ts] //// + +=== /index.mts === +import { value } from "provider"; +>value : number + +value; +>value : number + +=== /node_modules/provider/types.d.ts === +export const value: number; +>value : number + diff --git a/tsc/testdata/baselines/reference/compiler/conditionalExportsRequireTypesFallback.symbols b/tsc/testdata/baselines/reference/compiler/conditionalExportsRequireTypesFallback.symbols new file mode 100644 index 0000000000000..dedbedd3aa8a8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conditionalExportsRequireTypesFallback.symbols @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/conditionalExportsRequireTypesFallback.ts] //// + +=== /index.cts === +import { value } from "provider"; +>value : Symbol(value, Decl(index.cts, 0, 8)) + +value; +>value : Symbol(value, Decl(index.cts, 0, 8)) + +=== /node_modules/provider/index.d.ts === +export const value: number; +>value : Symbol(value, Decl(index.d.ts, 0, 12)) + diff --git a/tsc/testdata/baselines/reference/compiler/conditionalExportsRequireTypesFallback.trace.json b/tsc/testdata/baselines/reference/compiler/conditionalExportsRequireTypesFallback.trace.json new file mode 100644 index 0000000000000..4d0a84f727021 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conditionalExportsRequireTypesFallback.trace.json @@ -0,0 +1,21 @@ +======== Resolving module 'provider' from '/index.cts'. ======== +Explicitly specified module resolution kind: 'NodeNext'. +Resolving in CJS mode with conditions 'require', 'types', 'node'. +File '/package.json' does not exist. +Loading module 'provider' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. +Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Found 'package.json' at '/node_modules/provider/package.json'. +Entering conditional exports. +Matched 'exports' condition 'require'. +Using 'exports' subpath '.' with target './index.cjs'. +File name '/node_modules/provider/index.cjs' has a '.cjs' extension - stripping it. +File '/node_modules/provider/index.cts' does not exist. +File '/node_modules/provider/index.d.cts' does not exist. +Failed to resolve under condition 'require'. +Matched 'exports' condition 'types'. +Using 'exports' subpath '.' with target './index.d.ts'. +File '/node_modules/provider/index.d.ts' exists - use it as a name resolution result. +Resolved under condition 'types'. +Exiting conditional exports. +Resolving real path for '/node_modules/provider/index.d.ts', result '/node_modules/provider/index.d.ts'. +======== Module name 'provider' was successfully resolved to '/node_modules/provider/index.d.ts'. ======== diff --git a/tsc/testdata/baselines/reference/compiler/conditionalExportsRequireTypesFallback.types b/tsc/testdata/baselines/reference/compiler/conditionalExportsRequireTypesFallback.types new file mode 100644 index 0000000000000..ff3e0151205c4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conditionalExportsRequireTypesFallback.types @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/conditionalExportsRequireTypesFallback.ts] //// + +=== /index.cts === +import { value } from "provider"; +>value : number + +value; +>value : number + +=== /node_modules/provider/index.d.ts === +export const value: number; +>value : number + diff --git a/tsc/testdata/baselines/reference/compiler/conditionalExportsTypesImportFallback.symbols b/tsc/testdata/baselines/reference/compiler/conditionalExportsTypesImportFallback.symbols new file mode 100644 index 0000000000000..5d370eeb27dcd --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conditionalExportsTypesImportFallback.symbols @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/conditionalExportsTypesImportFallback.ts] //// + +=== /index.mts === +import color from "theme/tokens"; +>color : Symbol(color, Decl(index.mts, 0, 6)) + +color; +>color : Symbol(color, Decl(index.mts, 0, 6)) + +=== /node_modules/theme/tokens.d.mts === +declare const color: string; +>color : Symbol(color, Decl(tokens.d.mts, 0, 13)) + +export default color; +>color : Symbol(color, Decl(tokens.d.mts, 0, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/conditionalExportsTypesImportFallback.trace.json b/tsc/testdata/baselines/reference/compiler/conditionalExportsTypesImportFallback.trace.json new file mode 100644 index 0000000000000..421bc7aed330a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conditionalExportsTypesImportFallback.trace.json @@ -0,0 +1,21 @@ +======== Resolving module 'theme/tokens' from '/index.mts'. ======== +Explicitly specified module resolution kind: 'Bundler'. +Resolving in CJS mode with conditions 'import', 'types'. +File '/package.json' does not exist. +Loading module 'theme/tokens' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. +Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Found 'package.json' at '/node_modules/theme/package.json'. +Entering conditional exports. +Matched 'exports' condition 'types'. +Using 'exports' subpath './tokens' with target './tokens.d.ts'. +File '/node_modules/theme/tokens.d.ts' does not exist. +Failed to resolve under condition 'types'. +Matched 'exports' condition 'import'. +Using 'exports' subpath './tokens' with target './tokens.mjs'. +File name '/node_modules/theme/tokens.mjs' has a '.mjs' extension - stripping it. +File '/node_modules/theme/tokens.mts' does not exist. +File '/node_modules/theme/tokens.d.mts' exists - use it as a name resolution result. +Resolved under condition 'import'. +Exiting conditional exports. +Resolving real path for '/node_modules/theme/tokens.d.mts', result '/node_modules/theme/tokens.d.mts'. +======== Module name 'theme/tokens' was successfully resolved to '/node_modules/theme/tokens.d.mts'. ======== diff --git a/tsc/testdata/baselines/reference/compiler/conditionalExportsTypesImportFallback.types b/tsc/testdata/baselines/reference/compiler/conditionalExportsTypesImportFallback.types new file mode 100644 index 0000000000000..7c8e954a6303e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conditionalExportsTypesImportFallback.types @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/conditionalExportsTypesImportFallback.ts] //// + +=== /index.mts === +import color from "theme/tokens"; +>color : string + +color; +>color : string + +=== /node_modules/theme/tokens.d.mts === +declare const color: string; +>color : string + +export default color; +>color : string + diff --git a/tsc/testdata/baselines/reference/compiler/conditionalFunctionUnionInference.symbols b/tsc/testdata/baselines/reference/compiler/conditionalFunctionUnionInference.symbols new file mode 100644 index 0000000000000..62dce6dbeabf9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conditionalFunctionUnionInference.symbols @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/conditionalFunctionUnionInference.ts] //// + +=== conditionalFunctionUnionInference.ts === +type DeepValue = T extends () => unknown ? T : +>DeepValue : Symbol(DeepValue, Decl(conditionalFunctionUnionInference.ts, 0, 0)) +>T : Symbol(T, Decl(conditionalFunctionUnionInference.ts, 0, 15)) +>T : Symbol(T, Decl(conditionalFunctionUnionInference.ts, 0, 15)) +>T : Symbol(T, Decl(conditionalFunctionUnionInference.ts, 0, 15)) + + { [K in keyof T]: DeepValue }; +>K : Symbol(K, Decl(conditionalFunctionUnionInference.ts, 1, 7)) +>T : Symbol(T, Decl(conditionalFunctionUnionInference.ts, 0, 15)) +>DeepValue : Symbol(DeepValue, Decl(conditionalFunctionUnionInference.ts, 0, 0)) +>T : Symbol(T, Decl(conditionalFunctionUnionInference.ts, 0, 15)) +>K : Symbol(K, Decl(conditionalFunctionUnionInference.ts, 1, 7)) + +declare function createValue(initialValue: DeepValue T)>): T; +>createValue : Symbol(createValue, Decl(conditionalFunctionUnionInference.ts, 1, 40)) +>T : Symbol(T, Decl(conditionalFunctionUnionInference.ts, 3, 29)) +>initialValue : Symbol(initialValue, Decl(conditionalFunctionUnionInference.ts, 3, 32)) +>DeepValue : Symbol(DeepValue, Decl(conditionalFunctionUnionInference.ts, 0, 0)) +>T : Symbol(T, Decl(conditionalFunctionUnionInference.ts, 3, 29)) +>T : Symbol(T, Decl(conditionalFunctionUnionInference.ts, 3, 29)) +>T : Symbol(T, Decl(conditionalFunctionUnionInference.ts, 3, 29)) + +const value = createValue(() => ({ ready: true })); +>value : Symbol(value, Decl(conditionalFunctionUnionInference.ts, 5, 5)) +>createValue : Symbol(createValue, Decl(conditionalFunctionUnionInference.ts, 1, 40)) +>ready : Symbol(ready, Decl(conditionalFunctionUnionInference.ts, 5, 34)) + +value.ready; +>value.ready : Symbol(ready, Decl(conditionalFunctionUnionInference.ts, 5, 34)) +>value : Symbol(value, Decl(conditionalFunctionUnionInference.ts, 5, 5)) +>ready : Symbol(ready, Decl(conditionalFunctionUnionInference.ts, 5, 34)) + diff --git a/tsc/testdata/baselines/reference/compiler/conditionalFunctionUnionInference.types b/tsc/testdata/baselines/reference/compiler/conditionalFunctionUnionInference.types new file mode 100644 index 0000000000000..def30ad1a676b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conditionalFunctionUnionInference.types @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/conditionalFunctionUnionInference.ts] //// + +=== conditionalFunctionUnionInference.ts === +type DeepValue = T extends () => unknown ? T : +>DeepValue : DeepValue + + { [K in keyof T]: DeepValue }; + +declare function createValue(initialValue: DeepValue T)>): T; +>createValue : (initialValue: DeepValue T)>) => T +>initialValue : (() => T) | DeepValue + +const value = createValue(() => ({ ready: true })); +>value : { ready: boolean; } +>createValue(() => ({ ready: true })) : { ready: boolean; } +>createValue : (initialValue: DeepValue T)>) => T +>() => ({ ready: true }) : () => { ready: boolean; } +>({ ready: true }) : { ready: true; } +>{ ready: true } : { ready: true; } +>ready : true +>true : true + +value.ready; +>value.ready : boolean +>value : { ready: boolean; } +>ready : boolean + diff --git a/tsc/testdata/baselines/reference/compiler/conditionalPromptInference.symbols b/tsc/testdata/baselines/reference/compiler/conditionalPromptInference.symbols new file mode 100644 index 0000000000000..2d4ea4e93c146 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conditionalPromptInference.symbols @@ -0,0 +1,48 @@ +//// [tests/cases/compiler/conditionalPromptInference.ts] //// + +=== conditionalPromptInference.ts === +declare function createPrompt( +>createPrompt : Symbol(createPrompt, Decl(conditionalPromptInference.ts, 0, 0)) +>Value : Symbol(Value, Decl(conditionalPromptInference.ts, 0, 30)) +>Config : Symbol(Config, Decl(conditionalPromptInference.ts, 0, 36)) + + view: (config: Config, done: (value: Value) => void) => void, +>view : Symbol(view, Decl(conditionalPromptInference.ts, 0, 45)) +>config : Symbol(config, Decl(conditionalPromptInference.ts, 1, 11)) +>Config : Symbol(Config, Decl(conditionalPromptInference.ts, 0, 36)) +>done : Symbol(done, Decl(conditionalPromptInference.ts, 1, 26)) +>value : Symbol(value, Decl(conditionalPromptInference.ts, 1, 34)) +>Value : Symbol(Value, Decl(conditionalPromptInference.ts, 0, 30)) + +): (config: Config) => Value; +>config : Symbol(config, Decl(conditionalPromptInference.ts, 2, 4)) +>Config : Symbol(Config, Decl(conditionalPromptInference.ts, 0, 36)) +>Value : Symbol(Value, Decl(conditionalPromptInference.ts, 0, 30)) + +const numberPrompt = createPrompt(( +>numberPrompt : Symbol(numberPrompt, Decl(conditionalPromptInference.ts, 4, 5)) +>createPrompt : Symbol(createPrompt, Decl(conditionalPromptInference.ts, 0, 0)) +>Required : Symbol(Required, Decl(conditionalPromptInference.ts, 4, 35)) + + config: { required?: Required }, +>config : Symbol(config, Decl(conditionalPromptInference.ts, 4, 61)) +>required : Symbol(required, Decl(conditionalPromptInference.ts, 5, 13)) +>Required : Symbol(Required, Decl(conditionalPromptInference.ts, 4, 35)) + + done: (value: Required extends true ? number : number | undefined) => void, +>done : Symbol(done, Decl(conditionalPromptInference.ts, 5, 36)) +>value : Symbol(value, Decl(conditionalPromptInference.ts, 6, 11)) +>Required : Symbol(Required, Decl(conditionalPromptInference.ts, 4, 35)) + +) => {}); + +const required: number = numberPrompt({ required: true }); +>required : Symbol(required, Decl(conditionalPromptInference.ts, 9, 5)) +>numberPrompt : Symbol(numberPrompt, Decl(conditionalPromptInference.ts, 4, 5)) +>required : Symbol(required, Decl(conditionalPromptInference.ts, 9, 45)) + +const optional: number | undefined = numberPrompt({ required: false }); +>optional : Symbol(optional, Decl(conditionalPromptInference.ts, 10, 5)) +>numberPrompt : Symbol(numberPrompt, Decl(conditionalPromptInference.ts, 4, 5)) +>required : Symbol(required, Decl(conditionalPromptInference.ts, 10, 58)) + diff --git a/tsc/testdata/baselines/reference/compiler/conditionalPromptInference.types b/tsc/testdata/baselines/reference/compiler/conditionalPromptInference.types new file mode 100644 index 0000000000000..d1457bdeff455 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/conditionalPromptInference.types @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/conditionalPromptInference.ts] //// + +=== conditionalPromptInference.ts === +declare function createPrompt( +>createPrompt : (view: (config: Config, done: (value: Value) => void) => void) => (config: Config) => Value + + view: (config: Config, done: (value: Value) => void) => void, +>view : (config: Config, done: (value: Value) => void) => void +>config : Config +>done : (value: Value) => void +>value : Value + +): (config: Config) => Value; +>config : Config + +const numberPrompt = createPrompt(( +>numberPrompt : (config: { required?: Required; }) => Required extends true ? number : number | undefined +>createPrompt(( config: { required?: Required }, done: (value: Required extends true ? number : number | undefined) => void,) => {}) : (config: { required?: Required; }) => Required extends true ? number : number | undefined +>createPrompt : (view: (config: Config, done: (value: Value) => void) => void) => (config: Config) => Value +>( config: { required?: Required }, done: (value: Required extends true ? number : number | undefined) => void,) => {} : (config: { required?: Required; }, done: (value: Required extends true ? number : number | undefined) => void) => void + + config: { required?: Required }, +>config : { required?: Required; } +>required : Required | undefined + + done: (value: Required extends true ? number : number | undefined) => void, +>done : (value: Required extends true ? number : number | undefined) => void +>value : Required extends true ? number : number | undefined +>true : true + +) => {}); + +const required: number = numberPrompt({ required: true }); +>required : number +>numberPrompt({ required: true }) : number +>numberPrompt : (config: { required?: Required; }) => Required extends true ? number : number | undefined +>true : true +>{ required: true } : { required: true; } +>required : true +>true : true + +const optional: number | undefined = numberPrompt({ required: false }); +>optional : number | undefined +>numberPrompt({ required: false }) : number | undefined +>numberPrompt : (config: { required?: Required; }) => Required extends true ? number : number | undefined +>false : false +>{ required: false } : { required: false; } +>required : false +>false : false + diff --git a/tsc/testdata/baselines/reference/compiler/contextualFactoryReturnToOptionalClassField.symbols b/tsc/testdata/baselines/reference/compiler/contextualFactoryReturnToOptionalClassField.symbols new file mode 100644 index 0000000000000..66cc491275490 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualFactoryReturnToOptionalClassField.symbols @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/contextualFactoryReturnToOptionalClassField.ts] //// + +=== contextualFactoryReturnToOptionalClassField.ts === +class Reply { value!: T; } +>Reply : Symbol(Reply, Decl(contextualFactoryReturnToOptionalClassField.ts, 0, 0)) +>T : Symbol(T, Decl(contextualFactoryReturnToOptionalClassField.ts, 0, 12)) +>value : Symbol(Reply.value, Decl(contextualFactoryReturnToOptionalClassField.ts, 0, 40)) +>T : Symbol(T, Decl(contextualFactoryReturnToOptionalClassField.ts, 0, 12)) + +declare function create unknown, R extends InstanceType>(ctor: Ctor): R; +>create : Symbol(create, Decl(contextualFactoryReturnToOptionalClassField.ts, 0, 53)) +>Ctor : Symbol(Ctor, Decl(contextualFactoryReturnToOptionalClassField.ts, 1, 24)) +>R : Symbol(R, Decl(contextualFactoryReturnToOptionalClassField.ts, 1, 55)) +>InstanceType : Symbol(InstanceType, Decl(lib.es5.d.ts, --, --)) +>Ctor : Symbol(Ctor, Decl(contextualFactoryReturnToOptionalClassField.ts, 1, 24)) +>ctor : Symbol(ctor, Decl(contextualFactoryReturnToOptionalClassField.ts, 1, 86)) +>Ctor : Symbol(Ctor, Decl(contextualFactoryReturnToOptionalClassField.ts, 1, 24)) +>R : Symbol(R, Decl(contextualFactoryReturnToOptionalClassField.ts, 1, 55)) + +class Container { +>Container : Symbol(Container, Decl(contextualFactoryReturnToOptionalClassField.ts, 1, 101)) +>T : Symbol(T, Decl(contextualFactoryReturnToOptionalClassField.ts, 2, 16)) + + item?: Reply; +>item : Symbol(Container.item, Decl(contextualFactoryReturnToOptionalClassField.ts, 2, 44)) +>Reply : Symbol(Reply, Decl(contextualFactoryReturnToOptionalClassField.ts, 0, 0)) +>T : Symbol(T, Decl(contextualFactoryReturnToOptionalClassField.ts, 2, 16)) + + initialize() { this.item = create(Reply); } +>initialize : Symbol(Container.initialize, Decl(contextualFactoryReturnToOptionalClassField.ts, 3, 20)) +>this.item : Symbol(Container.item, Decl(contextualFactoryReturnToOptionalClassField.ts, 2, 44)) +>this : Symbol(Container, Decl(contextualFactoryReturnToOptionalClassField.ts, 1, 101)) +>item : Symbol(Container.item, Decl(contextualFactoryReturnToOptionalClassField.ts, 2, 44)) +>create : Symbol(create, Decl(contextualFactoryReturnToOptionalClassField.ts, 0, 53)) +>Reply : Symbol(Reply, Decl(contextualFactoryReturnToOptionalClassField.ts, 0, 0)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/contextualFactoryReturnToOptionalClassField.types b/tsc/testdata/baselines/reference/compiler/contextualFactoryReturnToOptionalClassField.types new file mode 100644 index 0000000000000..d380cf0573ee0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualFactoryReturnToOptionalClassField.types @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/contextualFactoryReturnToOptionalClassField.ts] //// + +=== contextualFactoryReturnToOptionalClassField.ts === +class Reply { value!: T; } +>Reply : Reply +>value : T + +declare function create unknown, R extends InstanceType>(ctor: Ctor): R; +>create : unknown, R extends InstanceType>(ctor: Ctor) => R +>ctor : Ctor + +class Container { +>Container : Container + + item?: Reply; +>item : Reply | undefined + + initialize() { this.item = create(Reply); } +>initialize : () => void +>this.item = create(Reply) : Reply +>this.item : Reply | undefined +>this : this +>item : Reply | undefined +>create(Reply) : Reply +>create : unknown, R extends InstanceType>(ctor: Ctor) => R +>Reply : typeof Reply +} + diff --git a/tsc/testdata/baselines/reference/compiler/contextualGenericReturnToOptionalClassField.symbols b/tsc/testdata/baselines/reference/compiler/contextualGenericReturnToOptionalClassField.symbols new file mode 100644 index 0000000000000..215f6ad388cca --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualGenericReturnToOptionalClassField.symbols @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/contextualGenericReturnToOptionalClassField.ts] //// + +=== contextualGenericReturnToOptionalClassField.ts === +declare function lookup(): T; +>lookup : Symbol(lookup, Decl(contextualGenericReturnToOptionalClassField.ts, 0, 0)) +>T : Symbol(T, Decl(contextualGenericReturnToOptionalClassField.ts, 0, 24)) +>T : Symbol(T, Decl(contextualGenericReturnToOptionalClassField.ts, 0, 24)) + +class Container { +>Container : Symbol(Container, Decl(contextualGenericReturnToOptionalClassField.ts, 0, 56)) + + item?: { label: string }; +>item : Symbol(Container.item, Decl(contextualGenericReturnToOptionalClassField.ts, 1, 17)) +>label : Symbol(label, Decl(contextualGenericReturnToOptionalClassField.ts, 2, 12)) + + getLabel() { +>getLabel : Symbol(Container.getLabel, Decl(contextualGenericReturnToOptionalClassField.ts, 2, 29)) + + if (!this.item) this.item = lookup(); +>this.item : Symbol(Container.item, Decl(contextualGenericReturnToOptionalClassField.ts, 1, 17)) +>this : Symbol(Container, Decl(contextualGenericReturnToOptionalClassField.ts, 0, 56)) +>item : Symbol(Container.item, Decl(contextualGenericReturnToOptionalClassField.ts, 1, 17)) +>this.item : Symbol(Container.item, Decl(contextualGenericReturnToOptionalClassField.ts, 1, 17)) +>this : Symbol(Container, Decl(contextualGenericReturnToOptionalClassField.ts, 0, 56)) +>item : Symbol(Container.item, Decl(contextualGenericReturnToOptionalClassField.ts, 1, 17)) +>lookup : Symbol(lookup, Decl(contextualGenericReturnToOptionalClassField.ts, 0, 0)) + + return this.item.label; +>this.item.label : Symbol(label, Decl(contextualGenericReturnToOptionalClassField.ts, 2, 12)) +>this.item : Symbol(Container.item, Decl(contextualGenericReturnToOptionalClassField.ts, 1, 17)) +>this : Symbol(Container, Decl(contextualGenericReturnToOptionalClassField.ts, 0, 56)) +>item : Symbol(Container.item, Decl(contextualGenericReturnToOptionalClassField.ts, 1, 17)) +>label : Symbol(label, Decl(contextualGenericReturnToOptionalClassField.ts, 2, 12)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/contextualGenericReturnToOptionalClassField.types b/tsc/testdata/baselines/reference/compiler/contextualGenericReturnToOptionalClassField.types new file mode 100644 index 0000000000000..9620d0af078e2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualGenericReturnToOptionalClassField.types @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/contextualGenericReturnToOptionalClassField.ts] //// + +=== contextualGenericReturnToOptionalClassField.ts === +declare function lookup(): T; +>lookup : () => T + +class Container { +>Container : Container + + item?: { label: string }; +>item : { label: string; } | undefined +>label : string + + getLabel() { +>getLabel : () => string + + if (!this.item) this.item = lookup(); +>!this.item : boolean +>this.item : { label: string; } | undefined +>this : this +>item : { label: string; } | undefined +>this.item = lookup() : { label: string; } +>this.item : { label: string; } | undefined +>this : this +>item : { label: string; } | undefined +>lookup() : { label: string; } +>lookup : () => T + + return this.item.label; +>this.item.label : string +>this.item : { label: string; } +>this : this +>item : { label: string; } +>label : string + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback.js b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback.js new file mode 100644 index 0000000000000..6772baec879f7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback.js @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/contextualReturnArrayPatternCallback.ts] //// + +//// [contextualReturnArrayPatternCallback.ts] +interface Matcher { + matcher(): { match(value: Input): boolean; value?: Value }; +} +type Pattern = Input | Matcher | { [Key in keyof Input]?: Pattern }; +type ArrayElement = Input extends readonly (infer Value)[] ? Value : unknown; +declare function array>>(value: Value): Matcher; +declare function when unknown>(callback: Callback): Matcher; +declare function accept>(value: Value): void; + +accept({ + list: array({ + prop: when(value => { + const text: string = value; + return true; + }), + }), +}); + + +//// [contextualReturnArrayPatternCallback.js] +"use strict"; +accept({ + list: array({ + prop: when(value => { + const text = value; + return true; + }), + }), +}); diff --git a/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback.symbols b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback.symbols new file mode 100644 index 0000000000000..2e6faa18727fd --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback.symbols @@ -0,0 +1,89 @@ +//// [tests/cases/compiler/contextualReturnArrayPatternCallback.ts] //// + +=== contextualReturnArrayPatternCallback.ts === +interface Matcher { +>Matcher : Symbol(Matcher, Decl(contextualReturnArrayPatternCallback.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 0, 18)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 0, 24)) + + matcher(): { match(value: Input): boolean; value?: Value }; +>matcher : Symbol(Matcher.matcher, Decl(contextualReturnArrayPatternCallback.ts, 0, 43)) +>match : Symbol(match, Decl(contextualReturnArrayPatternCallback.ts, 1, 16)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 1, 23)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 0, 18)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 1, 46)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 0, 24)) +} +type Pattern = Input | Matcher | { [Key in keyof Input]?: Pattern }; +>Pattern : Symbol(Pattern, Decl(contextualReturnArrayPatternCallback.ts, 2, 1)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 3, 13)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 3, 13)) +>Matcher : Symbol(Matcher, Decl(contextualReturnArrayPatternCallback.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 3, 13)) +>Key : Symbol(Key, Decl(contextualReturnArrayPatternCallback.ts, 3, 50)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 3, 13)) +>Pattern : Symbol(Pattern, Decl(contextualReturnArrayPatternCallback.ts, 2, 1)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 3, 13)) +>Key : Symbol(Key, Decl(contextualReturnArrayPatternCallback.ts, 3, 50)) + +type ArrayElement = Input extends readonly (infer Value)[] ? Value : unknown; +>ArrayElement : Symbol(ArrayElement, Decl(contextualReturnArrayPatternCallback.ts, 3, 94)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 4, 18)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 4, 18)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 4, 56)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 4, 56)) + +declare function array>>(value: Value): Matcher; +>array : Symbol(array, Decl(contextualReturnArrayPatternCallback.ts, 4, 84)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 5, 23)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 5, 29)) +>Pattern : Symbol(Pattern, Decl(contextualReturnArrayPatternCallback.ts, 2, 1)) +>ArrayElement : Symbol(ArrayElement, Decl(contextualReturnArrayPatternCallback.ts, 3, 94)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 5, 23)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 5, 74)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 5, 29)) +>Matcher : Symbol(Matcher, Decl(contextualReturnArrayPatternCallback.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 5, 23)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 5, 29)) + +declare function when unknown>(callback: Callback): Matcher; +>when : Symbol(when, Decl(contextualReturnArrayPatternCallback.ts, 5, 111)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 6, 22)) +>Callback : Symbol(Callback, Decl(contextualReturnArrayPatternCallback.ts, 6, 28)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 6, 47)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 6, 22)) +>callback : Symbol(callback, Decl(contextualReturnArrayPatternCallback.ts, 6, 73)) +>Callback : Symbol(Callback, Decl(contextualReturnArrayPatternCallback.ts, 6, 28)) +>Matcher : Symbol(Matcher, Decl(contextualReturnArrayPatternCallback.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnArrayPatternCallback.ts, 6, 22)) + +declare function accept>(value: Value): void; +>accept : Symbol(accept, Decl(contextualReturnArrayPatternCallback.ts, 6, 109)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 7, 24)) +>Pattern : Symbol(Pattern, Decl(contextualReturnArrayPatternCallback.ts, 2, 1)) +>list : Symbol(list, Decl(contextualReturnArrayPatternCallback.ts, 7, 47)) +>prop : Symbol(prop, Decl(contextualReturnArrayPatternCallback.ts, 7, 55)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 7, 77)) +>Value : Symbol(Value, Decl(contextualReturnArrayPatternCallback.ts, 7, 24)) + +accept({ +>accept : Symbol(accept, Decl(contextualReturnArrayPatternCallback.ts, 6, 109)) + + list: array({ +>list : Symbol(list, Decl(contextualReturnArrayPatternCallback.ts, 9, 8)) +>array : Symbol(array, Decl(contextualReturnArrayPatternCallback.ts, 4, 84)) + + prop: when(value => { +>prop : Symbol(prop, Decl(contextualReturnArrayPatternCallback.ts, 10, 17)) +>when : Symbol(when, Decl(contextualReturnArrayPatternCallback.ts, 5, 111)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 11, 19)) + + const text: string = value; +>text : Symbol(text, Decl(contextualReturnArrayPatternCallback.ts, 12, 17)) +>value : Symbol(value, Decl(contextualReturnArrayPatternCallback.ts, 11, 19)) + + return true; + }), + }), +}); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback.types b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback.types new file mode 100644 index 0000000000000..8ae0e4c69acc3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualReturnArrayPatternCallback.types @@ -0,0 +1,60 @@ +//// [tests/cases/compiler/contextualReturnArrayPatternCallback.ts] //// + +=== contextualReturnArrayPatternCallback.ts === +interface Matcher { + matcher(): { match(value: Input): boolean; value?: Value }; +>matcher : () => { match(value: Input): boolean; value?: Value; } +>match : (value: Input) => boolean +>value : Input +>value : Value | undefined +} +type Pattern = Input | Matcher | { [Key in keyof Input]?: Pattern }; +>Pattern : Pattern + +type ArrayElement = Input extends readonly (infer Value)[] ? Value : unknown; +>ArrayElement : ArrayElement + +declare function array>>(value: Value): Matcher; +>array : >>(value: Value) => Matcher +>value : Value + +declare function when unknown>(callback: Callback): Matcher; +>when : unknown>(callback: Callback) => Matcher +>value : Input +>callback : Callback + +declare function accept>(value: Value): void; +>accept : >(value: Value) => void +>list : { prop: string; }[] +>prop : string +>value : Value + +accept({ +>accept({ list: array({ prop: when(value => { const text: string = value; return true; }), }),}) : void +>accept : >(value: Value) => void +>{ list: array({ prop: when(value => { const text: string = value; return true; }), }),} : { list: Matcher<{ prop: string; }[], { prop: Matcher; }>; } + + list: array({ +>list : Matcher<{ prop: string; }[], { prop: Matcher; }> +>array({ prop: when(value => { const text: string = value; return true; }), }) : Matcher<{ prop: string; }[], { prop: Matcher; }> +>array : >>(value: Value) => Matcher +>{ prop: when(value => { const text: string = value; return true; }), } : { prop: Matcher; } + + prop: when(value => { +>prop : Matcher +>when(value => { const text: string = value; return true; }) : Matcher +>when : unknown>(callback: Callback) => Matcher +>value => { const text: string = value; return true; } : (value: string) => boolean +>value : string + + const text: string = value; +>text : string +>value : string + + return true; +>true : true + + }), + }), +}); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualReturnRecursivePatternArguments.js b/tsc/testdata/baselines/reference/compiler/contextualReturnRecursivePatternArguments.js new file mode 100644 index 0000000000000..b027eee9db1d2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualReturnRecursivePatternArguments.js @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/contextualReturnRecursivePatternArguments.ts] //// + +//// [contextualReturnRecursivePatternArguments.ts] +interface Matcher { + matcher(): { match(value: Input): boolean; pattern?: Pattern }; +} +type Pattern = Input | Matcher | { [Key in keyof Input]?: Pattern }; +declare function union, ...Pattern[]]>(...patterns: Patterns): Matcher; +declare function optional>(value: Value): Matcher; +declare function intersection, ...Pattern[]]>(...values: Values): Matcher; +declare function accept>(value: Value): void; + +accept(optional({ + // @ts-expect-error + type: union("oops"), +})); +accept(intersection({ + // @ts-expect-error + type: union("oops"), +})); + + +//// [contextualReturnRecursivePatternArguments.js] +"use strict"; +accept(optional({ + // @ts-expect-error + type: union("oops"), +})); +accept(intersection({ + // @ts-expect-error + type: union("oops"), +})); diff --git a/tsc/testdata/baselines/reference/compiler/contextualReturnRecursivePatternArguments.symbols b/tsc/testdata/baselines/reference/compiler/contextualReturnRecursivePatternArguments.symbols new file mode 100644 index 0000000000000..9bda87af09993 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualReturnRecursivePatternArguments.symbols @@ -0,0 +1,98 @@ +//// [tests/cases/compiler/contextualReturnRecursivePatternArguments.ts] //// + +=== contextualReturnRecursivePatternArguments.ts === +interface Matcher { +>Matcher : Symbol(Matcher, Decl(contextualReturnRecursivePatternArguments.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 0, 18)) +>Pattern : Symbol(Pattern, Decl(contextualReturnRecursivePatternArguments.ts, 0, 24)) + + matcher(): { match(value: Input): boolean; pattern?: Pattern }; +>matcher : Symbol(Matcher.matcher, Decl(contextualReturnRecursivePatternArguments.ts, 0, 45)) +>match : Symbol(match, Decl(contextualReturnRecursivePatternArguments.ts, 1, 16)) +>value : Symbol(value, Decl(contextualReturnRecursivePatternArguments.ts, 1, 23)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 0, 18)) +>pattern : Symbol(pattern, Decl(contextualReturnRecursivePatternArguments.ts, 1, 46)) +>Pattern : Symbol(Pattern, Decl(contextualReturnRecursivePatternArguments.ts, 0, 24)) +} +type Pattern = Input | Matcher | { [Key in keyof Input]?: Pattern }; +>Pattern : Symbol(Pattern, Decl(contextualReturnRecursivePatternArguments.ts, 2, 1)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 3, 13)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 3, 13)) +>Matcher : Symbol(Matcher, Decl(contextualReturnRecursivePatternArguments.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 3, 13)) +>Key : Symbol(Key, Decl(contextualReturnRecursivePatternArguments.ts, 3, 50)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 3, 13)) +>Pattern : Symbol(Pattern, Decl(contextualReturnRecursivePatternArguments.ts, 2, 1)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 3, 13)) +>Key : Symbol(Key, Decl(contextualReturnRecursivePatternArguments.ts, 3, 50)) + +declare function union, ...Pattern[]]>(...patterns: Patterns): Matcher; +>union : Symbol(union, Decl(contextualReturnRecursivePatternArguments.ts, 3, 94)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 4, 23)) +>Patterns : Symbol(Patterns, Decl(contextualReturnRecursivePatternArguments.ts, 4, 29)) +>Pattern : Symbol(Pattern, Decl(contextualReturnRecursivePatternArguments.ts, 2, 1)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 4, 23)) +>Pattern : Symbol(Pattern, Decl(contextualReturnRecursivePatternArguments.ts, 2, 1)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 4, 23)) +>patterns : Symbol(patterns, Decl(contextualReturnRecursivePatternArguments.ts, 4, 95)) +>Patterns : Symbol(Patterns, Decl(contextualReturnRecursivePatternArguments.ts, 4, 29)) +>Matcher : Symbol(Matcher, Decl(contextualReturnRecursivePatternArguments.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 4, 23)) +>Patterns : Symbol(Patterns, Decl(contextualReturnRecursivePatternArguments.ts, 4, 29)) + +declare function optional>(value: Value): Matcher; +>optional : Symbol(optional, Decl(contextualReturnRecursivePatternArguments.ts, 4, 144)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 5, 26)) +>Value : Symbol(Value, Decl(contextualReturnRecursivePatternArguments.ts, 5, 32)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 5, 26)) +>Pattern : Symbol(Pattern, Decl(contextualReturnRecursivePatternArguments.ts, 2, 1)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 5, 26)) +>value : Symbol(value, Decl(contextualReturnRecursivePatternArguments.ts, 5, 97)) +>Value : Symbol(Value, Decl(contextualReturnRecursivePatternArguments.ts, 5, 32)) +>Matcher : Symbol(Matcher, Decl(contextualReturnRecursivePatternArguments.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 5, 26)) +>Value : Symbol(Value, Decl(contextualReturnRecursivePatternArguments.ts, 5, 32)) + +declare function intersection, ...Pattern[]]>(...values: Values): Matcher; +>intersection : Symbol(intersection, Decl(contextualReturnRecursivePatternArguments.ts, 5, 134)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 6, 30)) +>Values : Symbol(Values, Decl(contextualReturnRecursivePatternArguments.ts, 6, 36)) +>Pattern : Symbol(Pattern, Decl(contextualReturnRecursivePatternArguments.ts, 2, 1)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 6, 30)) +>Pattern : Symbol(Pattern, Decl(contextualReturnRecursivePatternArguments.ts, 2, 1)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 6, 30)) +>values : Symbol(values, Decl(contextualReturnRecursivePatternArguments.ts, 6, 100)) +>Values : Symbol(Values, Decl(contextualReturnRecursivePatternArguments.ts, 6, 36)) +>Matcher : Symbol(Matcher, Decl(contextualReturnRecursivePatternArguments.ts, 0, 0)) +>Input : Symbol(Input, Decl(contextualReturnRecursivePatternArguments.ts, 6, 30)) +>Values : Symbol(Values, Decl(contextualReturnRecursivePatternArguments.ts, 6, 36)) + +declare function accept>(value: Value): void; +>accept : Symbol(accept, Decl(contextualReturnRecursivePatternArguments.ts, 6, 143)) +>Value : Symbol(Value, Decl(contextualReturnRecursivePatternArguments.ts, 7, 24)) +>Pattern : Symbol(Pattern, Decl(contextualReturnRecursivePatternArguments.ts, 2, 1)) +>type : Symbol(type, Decl(contextualReturnRecursivePatternArguments.ts, 7, 47)) +>value : Symbol(value, Decl(contextualReturnRecursivePatternArguments.ts, 7, 68)) +>Value : Symbol(Value, Decl(contextualReturnRecursivePatternArguments.ts, 7, 24)) + +accept(optional({ +>accept : Symbol(accept, Decl(contextualReturnRecursivePatternArguments.ts, 6, 143)) +>optional : Symbol(optional, Decl(contextualReturnRecursivePatternArguments.ts, 4, 144)) + + // @ts-expect-error + type: union("oops"), +>type : Symbol(type, Decl(contextualReturnRecursivePatternArguments.ts, 9, 17)) +>union : Symbol(union, Decl(contextualReturnRecursivePatternArguments.ts, 3, 94)) + +})); +accept(intersection({ +>accept : Symbol(accept, Decl(contextualReturnRecursivePatternArguments.ts, 6, 143)) +>intersection : Symbol(intersection, Decl(contextualReturnRecursivePatternArguments.ts, 5, 134)) + + // @ts-expect-error + type: union("oops"), +>type : Symbol(type, Decl(contextualReturnRecursivePatternArguments.ts, 13, 21)) +>union : Symbol(union, Decl(contextualReturnRecursivePatternArguments.ts, 3, 94)) + +})); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualReturnRecursivePatternArguments.types b/tsc/testdata/baselines/reference/compiler/contextualReturnRecursivePatternArguments.types new file mode 100644 index 0000000000000..d0b3ccfc95aa5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualReturnRecursivePatternArguments.types @@ -0,0 +1,61 @@ +//// [tests/cases/compiler/contextualReturnRecursivePatternArguments.ts] //// + +=== contextualReturnRecursivePatternArguments.ts === +interface Matcher { + matcher(): { match(value: Input): boolean; pattern?: Pattern }; +>matcher : () => { match(value: Input): boolean; pattern?: Pattern; } +>match : (value: Input) => boolean +>value : Input +>pattern : Pattern | undefined +} +type Pattern = Input | Matcher | { [Key in keyof Input]?: Pattern }; +>Pattern : Pattern + +declare function union, ...Pattern[]]>(...patterns: Patterns): Matcher; +>union : , ...Pattern[]]>(...patterns: Patterns) => Matcher +>patterns : Patterns + +declare function optional>(value: Value): Matcher; +>optional : >(value: Value) => Matcher +>value : Value + +declare function intersection, ...Pattern[]]>(...values: Values): Matcher; +>intersection : , ...Pattern[]]>(...values: Values) => Matcher +>values : Values + +declare function accept>(value: Value): void; +>accept : >(value: Value) => void +>type : "a" | "b" +>value : Value + +accept(optional({ +>accept(optional({ // @ts-expect-error type: union("oops"),})) : void +>accept : >(value: Value) => void +>optional({ // @ts-expect-error type: union("oops"),}) : Matcher, ...Pattern<"a" | "b">[]]>; }> +>optional : >(value: Value) => Matcher +>{ // @ts-expect-error type: union("oops"),} : { type: Matcher<"a" | "b", readonly [Pattern<"a" | "b">, ...Pattern<"a" | "b">[]]>; } + + // @ts-expect-error + type: union("oops"), +>type : Matcher<"a" | "b", readonly [Pattern<"a" | "b">, ...Pattern<"a" | "b">[]]> +>union("oops") : Matcher<"a" | "b", readonly [Pattern<"a" | "b">, ...Pattern<"a" | "b">[]]> +>union : , ...Pattern[]]>(...patterns: Patterns) => Matcher +>"oops" : "oops" + +})); +accept(intersection({ +>accept(intersection({ // @ts-expect-error type: union("oops"),})) : void +>accept : >(value: Value) => void +>intersection({ // @ts-expect-error type: union("oops"),}) : Matcher, ...Pattern<"a" | "b">[]]>; }]> +>intersection : , ...Pattern[]]>(...values: Values) => Matcher +>{ // @ts-expect-error type: union("oops"),} : { type: Matcher<"a" | "b", readonly [Pattern<"a" | "b">, ...Pattern<"a" | "b">[]]>; } + + // @ts-expect-error + type: union("oops"), +>type : Matcher<"a" | "b", readonly [Pattern<"a" | "b">, ...Pattern<"a" | "b">[]]> +>union("oops") : Matcher<"a" | "b", readonly [Pattern<"a" | "b">, ...Pattern<"a" | "b">[]]> +>union : , ...Pattern[]]>(...patterns: Patterns) => Matcher +>"oops" : "oops" + +})); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualReturnSpreadPickInference.symbols b/tsc/testdata/baselines/reference/compiler/contextualReturnSpreadPickInference.symbols new file mode 100644 index 0000000000000..9dbfd185aaa27 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualReturnSpreadPickInference.symbols @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/contextualReturnSpreadPickInference.ts] //// + +=== contextualReturnSpreadPickInference.ts === +type Many = T | readonly T[]; +>Many : Symbol(Many, Decl(contextualReturnSpreadPickInference.ts, 0, 0)) +>T : Symbol(T, Decl(contextualReturnSpreadPickInference.ts, 0, 10)) +>T : Symbol(T, Decl(contextualReturnSpreadPickInference.ts, 0, 10)) +>T : Symbol(T, Decl(contextualReturnSpreadPickInference.ts, 0, 10)) + +declare function pick( +>pick : Symbol(pick, Decl(contextualReturnSpreadPickInference.ts, 0, 32)) +>T : Symbol(T, Decl(contextualReturnSpreadPickInference.ts, 1, 22)) +>Key : Symbol(Key, Decl(contextualReturnSpreadPickInference.ts, 1, 39)) +>T : Symbol(T, Decl(contextualReturnSpreadPickInference.ts, 1, 22)) + + object: T, +>object : Symbol(object, Decl(contextualReturnSpreadPickInference.ts, 1, 61)) +>T : Symbol(T, Decl(contextualReturnSpreadPickInference.ts, 1, 22)) + + ...props: Many[] +>props : Symbol(props, Decl(contextualReturnSpreadPickInference.ts, 2, 14)) +>Many : Symbol(Many, Decl(contextualReturnSpreadPickInference.ts, 0, 0)) +>Key : Symbol(Key, Decl(contextualReturnSpreadPickInference.ts, 1, 39)) + +): Pick; +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(contextualReturnSpreadPickInference.ts, 1, 22)) +>Key : Symbol(Key, Decl(contextualReturnSpreadPickInference.ts, 1, 39)) + +async function getPage(page: any): Promise<{ title: string; intro: string }> { +>getPage : Symbol(getPage, Decl(contextualReturnSpreadPickInference.ts, 4, 16)) +>page : Symbol(page, Decl(contextualReturnSpreadPickInference.ts, 6, 23)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>title : Symbol(title, Decl(contextualReturnSpreadPickInference.ts, 6, 44)) +>intro : Symbol(intro, Decl(contextualReturnSpreadPickInference.ts, 6, 59)) + + return { + title: "", +>title : Symbol(title, Decl(contextualReturnSpreadPickInference.ts, 7, 12)) + + ...pick(page, ["intro"]), +>pick : Symbol(pick, Decl(contextualReturnSpreadPickInference.ts, 0, 32)) +>page : Symbol(page, Decl(contextualReturnSpreadPickInference.ts, 6, 23)) + + }; +} + diff --git a/tsc/testdata/baselines/reference/compiler/contextualReturnSpreadPickInference.types b/tsc/testdata/baselines/reference/compiler/contextualReturnSpreadPickInference.types new file mode 100644 index 0000000000000..a7f6f7edc5c08 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualReturnSpreadPickInference.types @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/contextualReturnSpreadPickInference.ts] //// + +=== contextualReturnSpreadPickInference.ts === +type Many = T | readonly T[]; +>Many : Many + +declare function pick( +>pick : (object: T, ...props: Many[]) => Pick + + object: T, +>object : T + + ...props: Many[] +>props : Many[] + +): Pick; + +async function getPage(page: any): Promise<{ title: string; intro: string }> { +>getPage : (page: any) => Promise<{ title: string; intro: string; }> +>page : any +>title : string +>intro : string + + return { +>{ title: "", ...pick(page, ["intro"]), } : { title: string; intro: any; } + + title: "", +>title : string +>"" : "" + + ...pick(page, ["intro"]), +>pick(page, ["intro"]) : Pick +>pick : (object: T, ...props: Many[]) => Pick +>page : any +>["intro"] : "intro"[] +>"intro" : "intro" + + }; +} + diff --git a/tsc/testdata/baselines/reference/compiler/contextualRuleMessageInference.symbols b/tsc/testdata/baselines/reference/compiler/contextualRuleMessageInference.symbols new file mode 100644 index 0000000000000..79cd1036db42e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualRuleMessageInference.symbols @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/contextualRuleMessageInference.ts] //// + +=== contextualRuleMessageInference.ts === +type DeferredInference = [T][T extends unknown ? 0 : never]; +>DeferredInference : Symbol(DeferredInference, Decl(contextualRuleMessageInference.ts, 0, 0)) +>T : Symbol(T, Decl(contextualRuleMessageInference.ts, 0, 23)) +>T : Symbol(T, Decl(contextualRuleMessageInference.ts, 0, 23)) +>T : Symbol(T, Decl(contextualRuleMessageInference.ts, 0, 23)) + +declare function runRule( +>runRule : Symbol(runRule, Decl(contextualRuleMessageInference.ts, 0, 63)) +>Message : Symbol(Message, Decl(contextualRuleMessageInference.ts, 2, 25)) + + rule: Message, +>rule : Symbol(rule, Decl(contextualRuleMessageInference.ts, 2, 49)) +>Message : Symbol(Message, Decl(contextualRuleMessageInference.ts, 2, 25)) + + tests: { invalid: readonly { errors: readonly { messageId: DeferredInference }[] }[] }, +>tests : Symbol(tests, Decl(contextualRuleMessageInference.ts, 3, 18)) +>invalid : Symbol(invalid, Decl(contextualRuleMessageInference.ts, 4, 12)) +>errors : Symbol(errors, Decl(contextualRuleMessageInference.ts, 4, 32)) +>messageId : Symbol(messageId, Decl(contextualRuleMessageInference.ts, 4, 51)) +>DeferredInference : Symbol(DeferredInference, Decl(contextualRuleMessageInference.ts, 0, 0)) +>Message : Symbol(Message, Decl(contextualRuleMessageInference.ts, 2, 25)) + +): void; + +runRule("forbiddenAct", { +>runRule : Symbol(runRule, Decl(contextualRuleMessageInference.ts, 0, 63)) + + invalid: ["act()"].map(() => ({ +>invalid : Symbol(invalid, Decl(contextualRuleMessageInference.ts, 7, 25)) +>["act()"].map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) + + errors: [{ messageId: "forbiddenAct" }], +>errors : Symbol(errors, Decl(contextualRuleMessageInference.ts, 8, 35)) +>messageId : Symbol(messageId, Decl(contextualRuleMessageInference.ts, 9, 18)) + + })), +}); + diff --git a/tsc/testdata/baselines/reference/compiler/contextualRuleMessageInference.types b/tsc/testdata/baselines/reference/compiler/contextualRuleMessageInference.types new file mode 100644 index 0000000000000..18b64bcc540d4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/contextualRuleMessageInference.types @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/contextualRuleMessageInference.ts] //// + +=== contextualRuleMessageInference.ts === +type DeferredInference = [T][T extends unknown ? 0 : never]; +>DeferredInference : DeferredInference + +declare function runRule( +>runRule : (rule: Message, tests: { invalid: readonly { errors: readonly { messageId: DeferredInference; }[]; }[]; }) => void + + rule: Message, +>rule : Message + + tests: { invalid: readonly { errors: readonly { messageId: DeferredInference }[] }[] }, +>tests : { invalid: readonly { errors: readonly { messageId: DeferredInference; }[]; }[]; } +>invalid : readonly { errors: readonly { messageId: DeferredInference; }[]; }[] +>errors : readonly { messageId: DeferredInference; }[] +>messageId : DeferredInference + +): void; + +runRule("forbiddenAct", { +>runRule("forbiddenAct", { invalid: ["act()"].map(() => ({ errors: [{ messageId: "forbiddenAct" }], })),}) : void +>runRule : (rule: Message, tests: { invalid: readonly { errors: readonly { messageId: DeferredInference; }[]; }[]; }) => void +>"forbiddenAct" : "forbiddenAct" +>{ invalid: ["act()"].map(() => ({ errors: [{ messageId: "forbiddenAct" }], })),} : { invalid: { errors: { messageId: "forbiddenAct"; }[]; }[]; } + + invalid: ["act()"].map(() => ({ +>invalid : { errors: { messageId: "forbiddenAct"; }[]; }[] +>["act()"].map(() => ({ errors: [{ messageId: "forbiddenAct" }], })) : { errors: { messageId: "forbiddenAct"; }[]; }[] +>["act()"].map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] +>["act()"] : string[] +>"act()" : "act()" +>map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] +>() => ({ errors: [{ messageId: "forbiddenAct" }], }) : () => { errors: { messageId: "forbiddenAct"; }[]; } +>({ errors: [{ messageId: "forbiddenAct" }], }) : { errors: { messageId: "forbiddenAct"; }[]; } +>{ errors: [{ messageId: "forbiddenAct" }], } : { errors: { messageId: "forbiddenAct"; }[]; } + + errors: [{ messageId: "forbiddenAct" }], +>errors : { messageId: "forbiddenAct"; }[] +>[{ messageId: "forbiddenAct" }] : { messageId: "forbiddenAct"; }[] +>{ messageId: "forbiddenAct" } : { messageId: "forbiddenAct"; } +>messageId : "forbiddenAct" +>"forbiddenAct" : "forbiddenAct" + + })), +}); + diff --git a/tsc/testdata/baselines/reference/compiler/correlatedLabelNullishFallback.js b/tsc/testdata/baselines/reference/compiler/correlatedLabelNullishFallback.js new file mode 100644 index 0000000000000..2b2fa870c17e6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/correlatedLabelNullishFallback.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/correlatedLabelNullishFallback.ts] //// + +//// [correlatedLabelNullishFallback.ts] +function label(options: { label: string; alias: string } | { label: object; alias?: string }) { + if (typeof options.label === "string") return options.alias ?? options.label; +} + + +//// [correlatedLabelNullishFallback.js] +"use strict"; +function label(options) { + if (typeof options.label === "string") + return options.alias ?? options.label; +} diff --git a/tsc/testdata/baselines/reference/compiler/correlatedLabelNullishFallback.symbols b/tsc/testdata/baselines/reference/compiler/correlatedLabelNullishFallback.symbols new file mode 100644 index 0000000000000..93bf91eb9e082 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/correlatedLabelNullishFallback.symbols @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/correlatedLabelNullishFallback.ts] //// + +=== correlatedLabelNullishFallback.ts === +function label(options: { label: string; alias: string } | { label: object; alias?: string }) { +>label : Symbol(label, Decl(correlatedLabelNullishFallback.ts, 0, 0)) +>options : Symbol(options, Decl(correlatedLabelNullishFallback.ts, 0, 15)) +>label : Symbol(label, Decl(correlatedLabelNullishFallback.ts, 0, 25)) +>alias : Symbol(alias, Decl(correlatedLabelNullishFallback.ts, 0, 40)) +>label : Symbol(label, Decl(correlatedLabelNullishFallback.ts, 0, 60)) +>alias : Symbol(alias, Decl(correlatedLabelNullishFallback.ts, 0, 75)) + + if (typeof options.label === "string") return options.alias ?? options.label; +>options.label : Symbol(label, Decl(correlatedLabelNullishFallback.ts, 0, 25), Decl(correlatedLabelNullishFallback.ts, 0, 60)) +>options : Symbol(options, Decl(correlatedLabelNullishFallback.ts, 0, 15)) +>label : Symbol(label, Decl(correlatedLabelNullishFallback.ts, 0, 25), Decl(correlatedLabelNullishFallback.ts, 0, 60)) +>options.alias : Symbol(alias, Decl(correlatedLabelNullishFallback.ts, 0, 40), Decl(correlatedLabelNullishFallback.ts, 0, 75)) +>options : Symbol(options, Decl(correlatedLabelNullishFallback.ts, 0, 15)) +>alias : Symbol(alias, Decl(correlatedLabelNullishFallback.ts, 0, 40), Decl(correlatedLabelNullishFallback.ts, 0, 75)) +>options.label : Symbol(label, Decl(correlatedLabelNullishFallback.ts, 0, 25), Decl(correlatedLabelNullishFallback.ts, 0, 60)) +>options : Symbol(options, Decl(correlatedLabelNullishFallback.ts, 0, 15)) +>label : Symbol(label, Decl(correlatedLabelNullishFallback.ts, 0, 25), Decl(correlatedLabelNullishFallback.ts, 0, 60)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/correlatedLabelNullishFallback.types b/tsc/testdata/baselines/reference/compiler/correlatedLabelNullishFallback.types new file mode 100644 index 0000000000000..a8a3a0a14e1c1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/correlatedLabelNullishFallback.types @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/correlatedLabelNullishFallback.ts] //// + +=== correlatedLabelNullishFallback.ts === +function label(options: { label: string; alias: string } | { label: object; alias?: string }) { +>label : (options: { label: string; alias: string; } | { label: object; alias?: string; }) => string | undefined +>options : { label: string; alias: string; } | { label: object; alias?: string; } +>label : string +>alias : string +>label : object +>alias : string | undefined + + if (typeof options.label === "string") return options.alias ?? options.label; +>typeof options.label === "string" : boolean +>typeof options.label : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" +>options.label : string | object +>options : { label: string; alias: string; } | { label: object; alias?: string; } +>label : string | object +>"string" : "string" +>options.alias ?? options.label : string +>options.alias : string | undefined +>options : { label: string; alias: string; } | { label: object; alias?: string; } +>alias : string | undefined +>options.label : string +>options : { label: string; alias: string; } | { label: object; alias?: string; } +>label : string +} + diff --git a/tsc/testdata/baselines/reference/compiler/cssStyleDeclarationCompatibility.symbols b/tsc/testdata/baselines/reference/compiler/cssStyleDeclarationCompatibility.symbols new file mode 100644 index 0000000000000..8707bc5102cfc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/cssStyleDeclarationCompatibility.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/cssStyleDeclarationCompatibility.ts] //// + +=== cssStyleDeclarationCompatibility.ts === +declare const element: HTMLElement; +>element : Symbol(element, Decl(cssStyleDeclarationCompatibility.ts, 0, 13)) +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +const style: CSSStyleDeclaration = element.style; +>style : Symbol(style, Decl(cssStyleDeclarationCompatibility.ts, 1, 5)) +>CSSStyleDeclaration : Symbol(CSSStyleDeclaration, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>element.style : Symbol(ElementCSSInlineStyle.style, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>element : Symbol(element, Decl(cssStyleDeclarationCompatibility.ts, 0, 13)) +>style : Symbol(ElementCSSInlineStyle.style, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +[...element.style]; +>element.style : Symbol(ElementCSSInlineStyle.style, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>element : Symbol(element, Decl(cssStyleDeclarationCompatibility.ts, 0, 13)) +>style : Symbol(ElementCSSInlineStyle.style, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + diff --git a/tsc/testdata/baselines/reference/compiler/cssStyleDeclarationCompatibility.types b/tsc/testdata/baselines/reference/compiler/cssStyleDeclarationCompatibility.types new file mode 100644 index 0000000000000..4a92523a67a2b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/cssStyleDeclarationCompatibility.types @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/cssStyleDeclarationCompatibility.ts] //// + +=== cssStyleDeclarationCompatibility.ts === +declare const element: HTMLElement; +>element : HTMLElement + +const style: CSSStyleDeclaration = element.style; +>style : CSSStyleDeclaration +>element.style : CSSStyleDeclaration +>element : HTMLElement +>style : CSSStyleDeclaration + +[...element.style]; +>[...element.style] : string[] +>...element.style : string +>element.style : CSSStyleDeclaration +>element : HTMLElement +>style : CSSStyleDeclaration + diff --git a/tsc/testdata/baselines/reference/compiler/declarationDefaultImportSuggestion.symbols b/tsc/testdata/baselines/reference/compiler/declarationDefaultImportSuggestion.symbols new file mode 100644 index 0000000000000..ed9f45a318148 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/declarationDefaultImportSuggestion.symbols @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/declarationDefaultImportSuggestion.ts] //// + +=== store.d.ts === +export interface Store {} +>Store : Symbol(Store, Decl(store.d.ts, 0, 0)) + +=== main.ts === +import Store from "./store"; +>Store : Symbol(Store, Decl(main.ts, 0, 6)) + diff --git a/tsc/testdata/baselines/reference/compiler/declarationDefaultImportSuggestion.types b/tsc/testdata/baselines/reference/compiler/declarationDefaultImportSuggestion.types new file mode 100644 index 0000000000000..b997663115396 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/declarationDefaultImportSuggestion.types @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/declarationDefaultImportSuggestion.ts] //// + +=== store.d.ts === + +export interface Store {} + +=== main.ts === +import Store from "./store"; +>Store : typeof Store + diff --git a/tsc/testdata/baselines/reference/compiler/defaultRootDirExternalFiles.errors.txt b/tsc/testdata/baselines/reference/compiler/defaultRootDirExternalFiles.errors.txt new file mode 100644 index 0000000000000..e01a680e9d0ed --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultRootDirExternalFiles.errors.txt @@ -0,0 +1,25 @@ +error TS6059: File '/project/src/index.ts' is not under 'rootDir' '/project/example'. 'rootDir' is expected to contain all source files. + The file is in the program because: + Part of 'files' list in tsconfig.json +/project/example/tsconfig.json(3,9): error TS5011: The common source directory of 'tsconfig.json' is '../src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + + +!!! error TS6059: File '/project/src/index.ts' is not under 'rootDir' '/project/example'. 'rootDir' is expected to contain all source files. +!!! error TS6059: The file is in the program because: +!!! error TS6059: Part of 'files' list in tsconfig.json +!!! related TS1410 /project/example/tsconfig.json:5:15: File is matched by 'files' list specified here. +==== /project/example/tsconfig.json (1 errors) ==== + { + "compilerOptions": { + "outDir": "." + ~~~~~~~~ +!!! error TS5011: The common source directory of 'tsconfig.json' is '../src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. +!!! error TS5011: Visit https://aka.ms/ts6 for migration information. + }, + "files": ["../src/index.ts"] + } + +==== /project/src/index.ts (0 errors) ==== + export const value = 0; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/defaultRootDirExternalFiles.js b/tsc/testdata/baselines/reference/compiler/defaultRootDirExternalFiles.js new file mode 100644 index 0000000000000..fe1458d3c6ae3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultRootDirExternalFiles.js @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/defaultRootDirExternalFiles.ts] //// + +//// [index.ts] +export const value = 0; + + +//// [index.js] +export const value = 0; diff --git a/tsc/testdata/baselines/reference/compiler/defaultRootDirExternalFiles.symbols b/tsc/testdata/baselines/reference/compiler/defaultRootDirExternalFiles.symbols new file mode 100644 index 0000000000000..21796d308a5c8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultRootDirExternalFiles.symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/defaultRootDirExternalFiles.ts] //// + +=== /project/src/index.ts === +export const value = 0; +>value : Symbol(value, Decl(index.ts, 0, 12)) + diff --git a/tsc/testdata/baselines/reference/compiler/defaultRootDirExternalFiles.types b/tsc/testdata/baselines/reference/compiler/defaultRootDirExternalFiles.types new file mode 100644 index 0000000000000..8950714816e45 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultRootDirExternalFiles.types @@ -0,0 +1,7 @@ +//// [tests/cases/compiler/defaultRootDirExternalFiles.ts] //// + +=== /project/src/index.ts === +export const value = 0; +>value : 0 +>0 : 0 + diff --git a/tsc/testdata/baselines/reference/compiler/defaultRootDirInheritedInclude.errors.txt b/tsc/testdata/baselines/reference/compiler/defaultRootDirInheritedInclude.errors.txt new file mode 100644 index 0000000000000..bc1f6edc203d9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultRootDirInheritedInclude.errors.txt @@ -0,0 +1,28 @@ +error TS5011: The common source directory of 'tsconfig.json' is '../src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. +error TS6059: File '/project/src/index.ts' is not under 'rootDir' '/project/example'. 'rootDir' is expected to contain all source files. + The file is in the program because: + Matched by include pattern '../src' in '/project/example/tsconfig.json' + + +!!! error TS5011: The common source directory of 'tsconfig.json' is '../src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. +!!! error TS5011: Visit https://aka.ms/ts6 for migration information. +!!! error TS6059: File '/project/src/index.ts' is not under 'rootDir' '/project/example'. 'rootDir' is expected to contain all source files. +!!! error TS6059: The file is in the program because: +!!! error TS6059: Matched by include pattern '../src' in '/project/example/tsconfig.json' +==== /project/example/tsconfig.json (0 errors) ==== + { + "extends": "../tsconfig.json" + } + +==== /project/src/index.ts (0 errors) ==== + export const value = 0; + +==== /project/tsconfig.json (0 errors) ==== + { + "compilerOptions": { + "outDir": "lib" + }, + "include": ["src"] + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/defaultRootDirInheritedInclude.js b/tsc/testdata/baselines/reference/compiler/defaultRootDirInheritedInclude.js new file mode 100644 index 0000000000000..fdebc4a1da7cb --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultRootDirInheritedInclude.js @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/defaultRootDirInheritedInclude.ts] //// + +//// [tsconfig.json] +{ + "compilerOptions": { + "outDir": "lib" + }, + "include": ["src"] +} + +//// [index.ts] +export const value = 0; + + +//// [index.js] +export const value = 0; diff --git a/tsc/testdata/baselines/reference/compiler/defaultRootDirInheritedInclude.symbols b/tsc/testdata/baselines/reference/compiler/defaultRootDirInheritedInclude.symbols new file mode 100644 index 0000000000000..3785ff1e67011 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultRootDirInheritedInclude.symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/defaultRootDirInheritedInclude.ts] //// + +=== /project/src/index.ts === +export const value = 0; +>value : Symbol(value, Decl(index.ts, 0, 12)) + diff --git a/tsc/testdata/baselines/reference/compiler/defaultRootDirInheritedInclude.types b/tsc/testdata/baselines/reference/compiler/defaultRootDirInheritedInclude.types new file mode 100644 index 0000000000000..75f03aa99ea74 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultRootDirInheritedInclude.types @@ -0,0 +1,7 @@ +//// [tests/cases/compiler/defaultRootDirInheritedInclude.ts] //// + +=== /project/src/index.ts === +export const value = 0; +>value : 0 +>0 : 0 + diff --git a/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientModuleImports.errors.txt b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientModuleImports.errors.txt new file mode 100644 index 0000000000000..0f24a5b5f7739 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientModuleImports.errors.txt @@ -0,0 +1,18 @@ +/main.mts(1,23): error TS2307: Cannot find module 'engine' or its corresponding type declarations. +/main.mts(2,35): error TS2307: Cannot find module 'engine' or its corresponding type declarations. + + +==== /main.mts (2 errors) ==== + import { value } from "engine"; + ~~~~~~~~ +!!! error TS2307: Cannot find module 'engine' or its corresponding type declarations. + export { default as engine } from "engine"; + ~~~~~~~~ +!!! error TS2307: Cannot find module 'engine' or its corresponding type declarations. + +==== /node_modules/@types/runtime/index.d.ts (0 errors) ==== + declare module "engine" { + export const value: number; + export default function read(): void; + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientModuleImports.symbols b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientModuleImports.symbols new file mode 100644 index 0000000000000..31adc13e21164 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientModuleImports.symbols @@ -0,0 +1,9 @@ +//// [tests/cases/compiler/defaultTypesExcludeAmbientModuleImports.ts] //// + +=== /main.mts === +import { value } from "engine"; +>value : Symbol(value, Decl(main.mts, 0, 8)) + +export { default as engine } from "engine"; +>engine : Symbol(engine, Decl(main.mts, 1, 8)) + diff --git a/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientModuleImports.types b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientModuleImports.types new file mode 100644 index 0000000000000..b1675f86581fa --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientModuleImports.types @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/defaultTypesExcludeAmbientModuleImports.ts] //// + +=== /main.mts === +import { value } from "engine"; +>value : any + +export { default as engine } from "engine"; +>default : any +>engine : any + diff --git a/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientPackages.errors.txt b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientPackages.errors.txt new file mode 100644 index 0000000000000..f505bd432cffc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientPackages.errors.txt @@ -0,0 +1,11 @@ +/main.ts(1,1): error TS2304: Cannot find name '__dirname'. + + +==== /main.ts (1 errors) ==== + __dirname; + ~~~~~~~~~ +!!! error TS2304: Cannot find name '__dirname'. + +==== /node_modules/@types/runtime/index.d.ts (0 errors) ==== + declare const __dirname: string; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientPackages.symbols b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientPackages.symbols new file mode 100644 index 0000000000000..6aff4ee8da081 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientPackages.symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/defaultTypesExcludeAmbientPackages.ts] //// + +=== /main.ts === + +__dirname; + diff --git a/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientPackages.types b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientPackages.types new file mode 100644 index 0000000000000..667d58b9fd911 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeAmbientPackages.types @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/defaultTypesExcludeAmbientPackages.ts] //// + +=== /main.ts === +__dirname; +>__dirname : any + diff --git a/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeBaseLibraryReferences.errors.txt b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeBaseLibraryReferences.errors.txt new file mode 100644 index 0000000000000..75bdcdc5361ab --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeBaseLibraryReferences.errors.txt @@ -0,0 +1,20 @@ +error TS2318: Cannot find global type 'Boolean'. +error TS2318: Cannot find global type 'CallableFunction'. +error TS2318: Cannot find global type 'IArguments'. +error TS2318: Cannot find global type 'NewableFunction'. +error TS2318: Cannot find global type 'Number'. +error TS2318: Cannot find global type 'Object'. + + +!!! error TS2318: Cannot find global type 'Boolean'. +!!! error TS2318: Cannot find global type 'CallableFunction'. +!!! error TS2318: Cannot find global type 'IArguments'. +!!! error TS2318: Cannot find global type 'NewableFunction'. +!!! error TS2318: Cannot find global type 'Number'. +!!! error TS2318: Cannot find global type 'Object'. +==== /main.ts (0 errors) ==== + export {}; + +==== /node_modules/@types/runtime/index.d.ts (0 errors) ==== + /// + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeBaseLibraryReferences.symbols b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeBaseLibraryReferences.symbols new file mode 100644 index 0000000000000..0609c95cf6c15 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeBaseLibraryReferences.symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/defaultTypesExcludeBaseLibraryReferences.ts] //// + +=== /main.ts === + +export {}; + diff --git a/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeBaseLibraryReferences.types b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeBaseLibraryReferences.types new file mode 100644 index 0000000000000..0609c95cf6c15 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeBaseLibraryReferences.types @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/defaultTypesExcludeBaseLibraryReferences.ts] //// + +=== /main.ts === + +export {}; + diff --git a/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeLibraryReferences.errors.txt b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeLibraryReferences.errors.txt new file mode 100644 index 0000000000000..47cd0667c4995 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeLibraryReferences.errors.txt @@ -0,0 +1,11 @@ +/main.ts(1,18): error TS2550: Property 'includes' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2016' or later. + + +==== /main.ts (1 errors) ==== + ["workflow.yml"].includes("workflow.yml"); + ~~~~~~~~ +!!! error TS2550: Property 'includes' does not exist on type 'string[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2016' or later. + +==== /node_modules/@types/runtime/index.d.ts (0 errors) ==== + /// + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeLibraryReferences.symbols b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeLibraryReferences.symbols new file mode 100644 index 0000000000000..e3e9f712e2b06 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeLibraryReferences.symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/defaultTypesExcludeLibraryReferences.ts] //// + +=== /main.ts === + +["workflow.yml"].includes("workflow.yml"); + diff --git a/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeLibraryReferences.types b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeLibraryReferences.types new file mode 100644 index 0000000000000..e693b144f12df --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultTypesExcludeLibraryReferences.types @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/defaultTypesExcludeLibraryReferences.ts] //// + +=== /main.ts === +["workflow.yml"].includes("workflow.yml"); +>["workflow.yml"].includes("workflow.yml") : any +>["workflow.yml"].includes : any +>["workflow.yml"] : string[] +>"workflow.yml" : "workflow.yml" +>includes : any +>"workflow.yml" : "workflow.yml" + diff --git a/tsc/testdata/baselines/reference/compiler/defaultWeakMapInferredPropertyAssignment.js b/tsc/testdata/baselines/reference/compiler/defaultWeakMapInferredPropertyAssignment.js new file mode 100644 index 0000000000000..20bddf727487d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultWeakMapInferredPropertyAssignment.js @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/defaultWeakMapInferredPropertyAssignment.ts] //// + +//// [defaultWeakMapInferredPropertyAssignment.ts] +const frameInfo = { frames: new WeakMap() }; +const target: { frames: WeakMap<{ id: string }, number> } = frameInfo; + + +//// [defaultWeakMapInferredPropertyAssignment.js] +"use strict"; +const frameInfo = { frames: new WeakMap() }; +const target = frameInfo; diff --git a/tsc/testdata/baselines/reference/compiler/defaultWeakMapInferredPropertyAssignment.symbols b/tsc/testdata/baselines/reference/compiler/defaultWeakMapInferredPropertyAssignment.symbols new file mode 100644 index 0000000000000..38d0d548057a2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultWeakMapInferredPropertyAssignment.symbols @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/defaultWeakMapInferredPropertyAssignment.ts] //// + +=== defaultWeakMapInferredPropertyAssignment.ts === +const frameInfo = { frames: new WeakMap() }; +>frameInfo : Symbol(frameInfo, Decl(defaultWeakMapInferredPropertyAssignment.ts, 0, 5)) +>frames : Symbol(frames, Decl(defaultWeakMapInferredPropertyAssignment.ts, 0, 19)) +>WeakMap : Symbol(WeakMap, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + +const target: { frames: WeakMap<{ id: string }, number> } = frameInfo; +>target : Symbol(target, Decl(defaultWeakMapInferredPropertyAssignment.ts, 1, 5)) +>frames : Symbol(frames, Decl(defaultWeakMapInferredPropertyAssignment.ts, 1, 15)) +>WeakMap : Symbol(WeakMap, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>id : Symbol(id, Decl(defaultWeakMapInferredPropertyAssignment.ts, 1, 33)) +>frameInfo : Symbol(frameInfo, Decl(defaultWeakMapInferredPropertyAssignment.ts, 0, 5)) + diff --git a/tsc/testdata/baselines/reference/compiler/defaultWeakMapInferredPropertyAssignment.types b/tsc/testdata/baselines/reference/compiler/defaultWeakMapInferredPropertyAssignment.types new file mode 100644 index 0000000000000..e3c5579725a9c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/defaultWeakMapInferredPropertyAssignment.types @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/defaultWeakMapInferredPropertyAssignment.ts] //// + +=== defaultWeakMapInferredPropertyAssignment.ts === +const frameInfo = { frames: new WeakMap() }; +>frameInfo : { frames: WeakMap; } +>{ frames: new WeakMap() } : { frames: WeakMap; } +>frames : WeakMap +>new WeakMap() : WeakMap +>WeakMap : WeakMapConstructor + +const target: { frames: WeakMap<{ id: string }, number> } = frameInfo; +>target : { frames: WeakMap<{ id: string; }, number>; } +>frames : WeakMap<{ id: string; }, number> +>id : string +>frameInfo : { frames: WeakMap; } + diff --git a/tsc/testdata/baselines/reference/compiler/distributedRecursiveMappedType.errors.txt b/tsc/testdata/baselines/reference/compiler/distributedRecursiveMappedType.errors.txt new file mode 100644 index 0000000000000..66c57a4a4b4b6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/distributedRecursiveMappedType.errors.txt @@ -0,0 +1,17 @@ +distributedRecursiveMappedType.ts(2,49): error TS2344: Type 'Input[Key]' does not satisfy the constraint 'Shape[Key]'. + Type 'Input' is not assignable to type 'Shape'. + 'Input' is only assignable to the non-distributed 'Shape', but 'Shape' has been distributed here. +distributedRecursiveMappedType.ts(2,49): error TS2536: Type 'Key' cannot be used to index type 'Input'. + + +==== distributedRecursiveMappedType.ts (2 errors) ==== + type Exact = Shape extends Shape + ? { [Key in keyof Shape]: Exact } + ~~~~~~~~~~ +!!! error TS2344: Type 'Input[Key]' does not satisfy the constraint 'Shape[Key]'. +!!! error TS2344: Type 'Input' is not assignable to type 'Shape'. +!!! error TS2344: 'Input' is only assignable to the non-distributed 'Shape', but 'Shape' has been distributed here. + ~~~~~~~~~~ +!!! error TS2536: Type 'Key' cannot be used to index type 'Input'. + : never; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/distributedRecursiveMappedType.symbols b/tsc/testdata/baselines/reference/compiler/distributedRecursiveMappedType.symbols new file mode 100644 index 0000000000000..205107931779c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/distributedRecursiveMappedType.symbols @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/distributedRecursiveMappedType.ts] //// + +=== distributedRecursiveMappedType.ts === +type Exact = Shape extends Shape +>Exact : Symbol(Exact, Decl(distributedRecursiveMappedType.ts, 0, 0)) +>Shape : Symbol(Shape, Decl(distributedRecursiveMappedType.ts, 0, 11)) +>Input : Symbol(Input, Decl(distributedRecursiveMappedType.ts, 0, 17)) +>Shape : Symbol(Shape, Decl(distributedRecursiveMappedType.ts, 0, 11)) +>Shape : Symbol(Shape, Decl(distributedRecursiveMappedType.ts, 0, 11)) +>Shape : Symbol(Shape, Decl(distributedRecursiveMappedType.ts, 0, 11)) + + ? { [Key in keyof Shape]: Exact } +>Key : Symbol(Key, Decl(distributedRecursiveMappedType.ts, 1, 9)) +>Shape : Symbol(Shape, Decl(distributedRecursiveMappedType.ts, 0, 11)) +>Exact : Symbol(Exact, Decl(distributedRecursiveMappedType.ts, 0, 0)) +>Shape : Symbol(Shape, Decl(distributedRecursiveMappedType.ts, 0, 11)) +>Key : Symbol(Key, Decl(distributedRecursiveMappedType.ts, 1, 9)) +>Input : Symbol(Input, Decl(distributedRecursiveMappedType.ts, 0, 17)) +>Key : Symbol(Key, Decl(distributedRecursiveMappedType.ts, 1, 9)) + + : never; + diff --git a/tsc/testdata/baselines/reference/compiler/distributedRecursiveMappedType.types b/tsc/testdata/baselines/reference/compiler/distributedRecursiveMappedType.types new file mode 100644 index 0000000000000..06d9da380ea4b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/distributedRecursiveMappedType.types @@ -0,0 +1,9 @@ +//// [tests/cases/compiler/distributedRecursiveMappedType.ts] //// + +=== distributedRecursiveMappedType.ts === +type Exact = Shape extends Shape +>Exact : Exact + + ? { [Key in keyof Shape]: Exact } + : never; + diff --git a/tsc/testdata/baselines/reference/compiler/domBaseElementToSpan.js b/tsc/testdata/baselines/reference/compiler/domBaseElementToSpan.js new file mode 100644 index 0000000000000..434821cf24a4f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domBaseElementToSpan.js @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/domBaseElementToSpan.ts] //// + +//// [domBaseElementToSpan.ts] +declare const element: HTMLElement; +const span: HTMLSpanElement = element; + + +//// [domBaseElementToSpan.js] +"use strict"; +const span = element; diff --git a/tsc/testdata/baselines/reference/compiler/domBaseElementToSpan.symbols b/tsc/testdata/baselines/reference/compiler/domBaseElementToSpan.symbols new file mode 100644 index 0000000000000..6b0cbd7fad421 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domBaseElementToSpan.symbols @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/domBaseElementToSpan.ts] //// + +=== domBaseElementToSpan.ts === +declare const element: HTMLElement; +>element : Symbol(element, Decl(domBaseElementToSpan.ts, 0, 13)) +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +const span: HTMLSpanElement = element; +>span : Symbol(span, Decl(domBaseElementToSpan.ts, 1, 5)) +>HTMLSpanElement : Symbol(HTMLSpanElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>element : Symbol(element, Decl(domBaseElementToSpan.ts, 0, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/domBaseElementToSpan.types b/tsc/testdata/baselines/reference/compiler/domBaseElementToSpan.types new file mode 100644 index 0000000000000..6f70e2948c150 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domBaseElementToSpan.types @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/domBaseElementToSpan.ts] //// + +=== domBaseElementToSpan.ts === +declare const element: HTMLElement; +>element : HTMLElement + +const span: HTMLSpanElement = element; +>span : HTMLSpanElement +>element : HTMLElement + diff --git a/tsc/testdata/baselines/reference/compiler/domDirectoryReaderArrayCallbacks.js b/tsc/testdata/baselines/reference/compiler/domDirectoryReaderArrayCallbacks.js new file mode 100644 index 0000000000000..bfe680b32ecb8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domDirectoryReaderArrayCallbacks.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/domDirectoryReaderArrayCallbacks.ts] //// + +//// [domDirectoryReaderArrayCallbacks.ts] +declare const reader: FileSystemDirectoryReader; +reader.readEntries(entries => entries.length); +reader.readEntries(async (entries: FileSystemEntry[]) => {}); +new Promise(resolve => reader.readEntries(resolve)); + + +//// [domDirectoryReaderArrayCallbacks.js] +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +reader.readEntries(entries => entries.length); +reader.readEntries((entries) => __awaiter(void 0, void 0, void 0, function* () { })); +new Promise(resolve => reader.readEntries(resolve)); diff --git a/tsc/testdata/baselines/reference/compiler/domDirectoryReaderArrayCallbacks.symbols b/tsc/testdata/baselines/reference/compiler/domDirectoryReaderArrayCallbacks.symbols new file mode 100644 index 0000000000000..b6647fa6f7a44 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domDirectoryReaderArrayCallbacks.symbols @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/domDirectoryReaderArrayCallbacks.ts] //// + +=== domDirectoryReaderArrayCallbacks.ts === +declare const reader: FileSystemDirectoryReader; +>reader : Symbol(reader, Decl(domDirectoryReaderArrayCallbacks.ts, 0, 13)) +>FileSystemDirectoryReader : Symbol(FileSystemDirectoryReader, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +reader.readEntries(entries => entries.length); +>reader.readEntries : Symbol(FileSystemDirectoryReader.readEntries, Decl(lib.dom.d.ts, --, --)) +>reader : Symbol(reader, Decl(domDirectoryReaderArrayCallbacks.ts, 0, 13)) +>readEntries : Symbol(FileSystemDirectoryReader.readEntries, Decl(lib.dom.d.ts, --, --)) +>entries : Symbol(entries, Decl(domDirectoryReaderArrayCallbacks.ts, 1, 19)) +>entries.length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) +>entries : Symbol(entries, Decl(domDirectoryReaderArrayCallbacks.ts, 1, 19)) +>length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) + +reader.readEntries(async (entries: FileSystemEntry[]) => {}); +>reader.readEntries : Symbol(FileSystemDirectoryReader.readEntries, Decl(lib.dom.d.ts, --, --)) +>reader : Symbol(reader, Decl(domDirectoryReaderArrayCallbacks.ts, 0, 13)) +>readEntries : Symbol(FileSystemDirectoryReader.readEntries, Decl(lib.dom.d.ts, --, --)) +>entries : Symbol(entries, Decl(domDirectoryReaderArrayCallbacks.ts, 2, 26)) +>FileSystemEntry : Symbol(FileSystemEntry, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +new Promise(resolve => reader.readEntries(resolve)); +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>FileSystemEntry : Symbol(FileSystemEntry, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>resolve : Symbol(resolve, Decl(domDirectoryReaderArrayCallbacks.ts, 3, 40)) +>reader.readEntries : Symbol(FileSystemDirectoryReader.readEntries, Decl(lib.dom.d.ts, --, --)) +>reader : Symbol(reader, Decl(domDirectoryReaderArrayCallbacks.ts, 0, 13)) +>readEntries : Symbol(FileSystemDirectoryReader.readEntries, Decl(lib.dom.d.ts, --, --)) +>resolve : Symbol(resolve, Decl(domDirectoryReaderArrayCallbacks.ts, 3, 40)) + diff --git a/tsc/testdata/baselines/reference/compiler/domDirectoryReaderArrayCallbacks.types b/tsc/testdata/baselines/reference/compiler/domDirectoryReaderArrayCallbacks.types new file mode 100644 index 0000000000000..c8a79cefb0191 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domDirectoryReaderArrayCallbacks.types @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/domDirectoryReaderArrayCallbacks.ts] //// + +=== domDirectoryReaderArrayCallbacks.ts === +declare const reader: FileSystemDirectoryReader; +>reader : FileSystemDirectoryReader + +reader.readEntries(entries => entries.length); +>reader.readEntries(entries => entries.length) : void +>reader.readEntries : (successCallback: FileSystemEntriesCallback, errorCallback?: ErrorCallback) => void +>reader : FileSystemDirectoryReader +>readEntries : (successCallback: FileSystemEntriesCallback, errorCallback?: ErrorCallback) => void +>entries => entries.length : (entries: FileSystemEntry[]) => number +>entries : FileSystemEntry[] +>entries.length : number +>entries : FileSystemEntry[] +>length : number + +reader.readEntries(async (entries: FileSystemEntry[]) => {}); +>reader.readEntries(async (entries: FileSystemEntry[]) => {}) : void +>reader.readEntries : (successCallback: FileSystemEntriesCallback, errorCallback?: ErrorCallback) => void +>reader : FileSystemDirectoryReader +>readEntries : (successCallback: FileSystemEntriesCallback, errorCallback?: ErrorCallback) => void +>async (entries: FileSystemEntry[]) => {} : (entries: FileSystemEntry[]) => Promise +>entries : FileSystemEntry[] + +new Promise(resolve => reader.readEntries(resolve)); +>new Promise(resolve => reader.readEntries(resolve)) : Promise +>Promise : PromiseConstructor +>resolve => reader.readEntries(resolve) : (resolve: (value: PromiseLike | readonly FileSystemEntry[]) => void) => void +>resolve : (value: PromiseLike | readonly FileSystemEntry[]) => void +>reader.readEntries(resolve) : void +>reader.readEntries : (successCallback: FileSystemEntriesCallback, errorCallback?: ErrorCallback) => void +>reader : FileSystemDirectoryReader +>readEntries : (successCallback: FileSystemEntriesCallback, errorCallback?: ErrorCallback) => void +>resolve : (value: PromiseLike | readonly FileSystemEntry[]) => void + diff --git a/tsc/testdata/baselines/reference/compiler/domElementStringKeyConstraint.js b/tsc/testdata/baselines/reference/compiler/domElementStringKeyConstraint.js new file mode 100644 index 0000000000000..a200d2d37dc84 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domElementStringKeyConstraint.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/domElementStringKeyConstraint.ts] //// + +//// [domElementStringKeyConstraint.ts] +declare function setProperty(element: T, property: K, value: T[K]): void; +declare const element: Element; +declare const key: keyof Element; +setProperty(element, key, true); + + +//// [domElementStringKeyConstraint.js] +"use strict"; +setProperty(element, key, true); diff --git a/tsc/testdata/baselines/reference/compiler/domElementStringKeyConstraint.symbols b/tsc/testdata/baselines/reference/compiler/domElementStringKeyConstraint.symbols new file mode 100644 index 0000000000000..4cb2a7b66b102 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domElementStringKeyConstraint.symbols @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/domElementStringKeyConstraint.ts] //// + +=== domElementStringKeyConstraint.ts === +declare function setProperty(element: T, property: K, value: T[K]): void; +>setProperty : Symbol(setProperty, Decl(domElementStringKeyConstraint.ts, 0, 0)) +>T : Symbol(T, Decl(domElementStringKeyConstraint.ts, 0, 29)) +>Element : Symbol(Element, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>K : Symbol(K, Decl(domElementStringKeyConstraint.ts, 0, 47)) +>T : Symbol(T, Decl(domElementStringKeyConstraint.ts, 0, 29)) +>element : Symbol(element, Decl(domElementStringKeyConstraint.ts, 0, 76)) +>T : Symbol(T, Decl(domElementStringKeyConstraint.ts, 0, 29)) +>property : Symbol(property, Decl(domElementStringKeyConstraint.ts, 0, 87)) +>K : Symbol(K, Decl(domElementStringKeyConstraint.ts, 0, 47)) +>value : Symbol(value, Decl(domElementStringKeyConstraint.ts, 0, 100)) +>T : Symbol(T, Decl(domElementStringKeyConstraint.ts, 0, 29)) +>K : Symbol(K, Decl(domElementStringKeyConstraint.ts, 0, 47)) + +declare const element: Element; +>element : Symbol(element, Decl(domElementStringKeyConstraint.ts, 1, 13)) +>Element : Symbol(Element, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +declare const key: keyof Element; +>key : Symbol(key, Decl(domElementStringKeyConstraint.ts, 2, 13)) +>Element : Symbol(Element, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +setProperty(element, key, true); +>setProperty : Symbol(setProperty, Decl(domElementStringKeyConstraint.ts, 0, 0)) +>element : Symbol(element, Decl(domElementStringKeyConstraint.ts, 1, 13)) +>key : Symbol(key, Decl(domElementStringKeyConstraint.ts, 2, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/domElementStringKeyConstraint.types b/tsc/testdata/baselines/reference/compiler/domElementStringKeyConstraint.types new file mode 100644 index 0000000000000..99863978a49e3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domElementStringKeyConstraint.types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/domElementStringKeyConstraint.ts] //// + +=== domElementStringKeyConstraint.ts === +declare function setProperty(element: T, property: K, value: T[K]): void; +>setProperty : (element: T, property: K, value: T[K]) => void +>element : T +>property : K +>value : T[K] + +declare const element: Element; +>element : Element + +declare const key: keyof Element; +>key : keyof Element + +setProperty(element, key, true); +>setProperty(element, key, true) : void +>setProperty : (element: T, property: K, value: T[K]) => void +>element : Element +>key : keyof Element +>true : true + diff --git a/tsc/testdata/baselines/reference/compiler/domIterableGenericDatasetKeys.errors.txt b/tsc/testdata/baselines/reference/compiler/domIterableGenericDatasetKeys.errors.txt new file mode 100644 index 0000000000000..352602cfb9faa --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domIterableGenericDatasetKeys.errors.txt @@ -0,0 +1,14 @@ +domIterableGenericDatasetKeys.ts(2,19): error TS2536: Type 'Key' cannot be used to index type 'DOMStringMap'. +domIterableGenericDatasetKeys.ts(3,12): error TS2536: Type 'Key' cannot be used to index type 'DOMStringMap'. + + +==== domIterableGenericDatasetKeys.ts (2 errors) ==== + function restore(key: Key, element: HTMLElement) { + const value = element.dataset[key]; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2536: Type 'Key' cannot be used to index type 'DOMStringMap'. + delete element.dataset[key]; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2536: Type 'Key' cannot be used to index type 'DOMStringMap'. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/domIterableGenericDatasetKeys.js b/tsc/testdata/baselines/reference/compiler/domIterableGenericDatasetKeys.js new file mode 100644 index 0000000000000..bf2c038e20928 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domIterableGenericDatasetKeys.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/domIterableGenericDatasetKeys.ts] //// + +//// [domIterableGenericDatasetKeys.ts] +function restore(key: Key, element: HTMLElement) { + const value = element.dataset[key]; + delete element.dataset[key]; +} + + +//// [domIterableGenericDatasetKeys.js] +"use strict"; +function restore(key, element) { + const value = element.dataset[key]; + delete element.dataset[key]; +} diff --git a/tsc/testdata/baselines/reference/compiler/domIterableGenericDatasetKeys.symbols b/tsc/testdata/baselines/reference/compiler/domIterableGenericDatasetKeys.symbols new file mode 100644 index 0000000000000..609042b3e9ec8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domIterableGenericDatasetKeys.symbols @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/domIterableGenericDatasetKeys.ts] //// + +=== domIterableGenericDatasetKeys.ts === +function restore(key: Key, element: HTMLElement) { +>restore : Symbol(restore, Decl(domIterableGenericDatasetKeys.ts, 0, 0)) +>Key : Symbol(Key, Decl(domIterableGenericDatasetKeys.ts, 0, 17)) +>CSSStyleDeclaration : Symbol(CSSStyleDeclaration, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>key : Symbol(key, Decl(domIterableGenericDatasetKeys.ts, 0, 56)) +>Key : Symbol(Key, Decl(domIterableGenericDatasetKeys.ts, 0, 17)) +>element : Symbol(element, Decl(domIterableGenericDatasetKeys.ts, 0, 65)) +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + const value = element.dataset[key]; +>value : Symbol(value, Decl(domIterableGenericDatasetKeys.ts, 1, 9)) +>element.dataset : Symbol(HTMLOrSVGOrMathMLElement.dataset, Decl(lib.dom.d.ts, --, --)) +>element : Symbol(element, Decl(domIterableGenericDatasetKeys.ts, 0, 65)) +>dataset : Symbol(HTMLOrSVGOrMathMLElement.dataset, Decl(lib.dom.d.ts, --, --)) +>key : Symbol(key, Decl(domIterableGenericDatasetKeys.ts, 0, 56)) + + delete element.dataset[key]; +>element.dataset : Symbol(HTMLOrSVGOrMathMLElement.dataset, Decl(lib.dom.d.ts, --, --)) +>element : Symbol(element, Decl(domIterableGenericDatasetKeys.ts, 0, 65)) +>dataset : Symbol(HTMLOrSVGOrMathMLElement.dataset, Decl(lib.dom.d.ts, --, --)) +>key : Symbol(key, Decl(domIterableGenericDatasetKeys.ts, 0, 56)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/domIterableGenericDatasetKeys.types b/tsc/testdata/baselines/reference/compiler/domIterableGenericDatasetKeys.types new file mode 100644 index 0000000000000..d2922190b7151 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domIterableGenericDatasetKeys.types @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/domIterableGenericDatasetKeys.ts] //// + +=== domIterableGenericDatasetKeys.ts === +function restore(key: Key, element: HTMLElement) { +>restore : (key: Key, element: HTMLElement) => void +>key : Key +>element : HTMLElement + + const value = element.dataset[key]; +>value : any +>element.dataset[key] : any +>element.dataset : DOMStringMap +>element : HTMLElement +>dataset : DOMStringMap +>key : Key + + delete element.dataset[key]; +>delete element.dataset[key] : boolean +>element.dataset[key] : any +>element.dataset : DOMStringMap +>element : HTMLElement +>dataset : DOMStringMap +>key : Key +} + diff --git a/tsc/testdata/baselines/reference/compiler/domIterableSymbolMappedValue.errors.txt b/tsc/testdata/baselines/reference/compiler/domIterableSymbolMappedValue.errors.txt new file mode 100644 index 0000000000000..8a01bf160bb5b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domIterableSymbolMappedValue.errors.txt @@ -0,0 +1,16 @@ +domIterableSymbolMappedValue.ts(3,9): error TS2345: Argument of type 'Partial>' is not assignable to parameter of type 'Partial>'. + Types of property '[iterator]' are incompatible. + Type '(() => ArrayIterator) | undefined' is not assignable to type 'string | undefined'. + Type '() => ArrayIterator' is not assignable to type 'string'. + + +==== domIterableSymbolMappedValue.ts (1 errors) ==== + declare const styles: Partial>; + declare function element(styles: Partial>): void; + element(styles); + ~~~~~~ +!!! error TS2345: Argument of type 'Partial>' is not assignable to parameter of type 'Partial>'. +!!! error TS2345: Types of property '[iterator]' are incompatible. +!!! error TS2345: Type '(() => ArrayIterator) | undefined' is not assignable to type 'string | undefined'. +!!! error TS2345: Type '() => ArrayIterator' is not assignable to type 'string'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/domIterableSymbolMappedValue.js b/tsc/testdata/baselines/reference/compiler/domIterableSymbolMappedValue.js new file mode 100644 index 0000000000000..98a3475277f56 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domIterableSymbolMappedValue.js @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/domIterableSymbolMappedValue.ts] //// + +//// [domIterableSymbolMappedValue.ts] +declare const styles: Partial>; +declare function element(styles: Partial>): void; +element(styles); + + +//// [domIterableSymbolMappedValue.js] +"use strict"; +element(styles); diff --git a/tsc/testdata/baselines/reference/compiler/domIterableSymbolMappedValue.symbols b/tsc/testdata/baselines/reference/compiler/domIterableSymbolMappedValue.symbols new file mode 100644 index 0000000000000..bda0738bcfe2e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domIterableSymbolMappedValue.symbols @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/domIterableSymbolMappedValue.ts] //// + +=== domIterableSymbolMappedValue.ts === +declare const styles: Partial>; +>styles : Symbol(styles, Decl(domIterableSymbolMappedValue.ts, 0, 13)) +>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>CSSStyleDeclaration : Symbol(CSSStyleDeclaration, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>CSSStyleDeclaration : Symbol(CSSStyleDeclaration, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +declare function element(styles: Partial>): void; +>element : Symbol(element, Decl(domIterableSymbolMappedValue.ts, 0, 93)) +>styles : Symbol(styles, Decl(domIterableSymbolMappedValue.ts, 1, 25)) +>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>CSSStyleDeclaration : Symbol(CSSStyleDeclaration, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +element(styles); +>element : Symbol(element, Decl(domIterableSymbolMappedValue.ts, 0, 93)) +>styles : Symbol(styles, Decl(domIterableSymbolMappedValue.ts, 0, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/domIterableSymbolMappedValue.types b/tsc/testdata/baselines/reference/compiler/domIterableSymbolMappedValue.types new file mode 100644 index 0000000000000..9dc7d5c608c27 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domIterableSymbolMappedValue.types @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/domIterableSymbolMappedValue.ts] //// + +=== domIterableSymbolMappedValue.ts === +declare const styles: Partial>; +>styles : Partial> + +declare function element(styles: Partial>): void; +>element : (styles: Partial>) => void +>styles : Partial> + +element(styles); +>element(styles) : void +>element : (styles: Partial>) => void +>styles : Partial> + diff --git a/tsc/testdata/baselines/reference/compiler/domObserverArrayCallbacks.js b/tsc/testdata/baselines/reference/compiler/domObserverArrayCallbacks.js new file mode 100644 index 0000000000000..314cadd4dbbf3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domObserverArrayCallbacks.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/domObserverArrayCallbacks.ts] //// + +//// [domObserverArrayCallbacks.ts] +new ResizeObserver(entries => entries[0]); +new MutationObserver(records => records.some(record => record.attributeName === "style")); +new IntersectionObserver(entries => entries.forEach(entry => entry.isIntersecting)); + + +//// [domObserverArrayCallbacks.js] +"use strict"; +new ResizeObserver(entries => entries[0]); +new MutationObserver(records => records.some(record => record.attributeName === "style")); +new IntersectionObserver(entries => entries.forEach(entry => entry.isIntersecting)); diff --git a/tsc/testdata/baselines/reference/compiler/domObserverArrayCallbacks.symbols b/tsc/testdata/baselines/reference/compiler/domObserverArrayCallbacks.symbols new file mode 100644 index 0000000000000..411f157f153e0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domObserverArrayCallbacks.symbols @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/domObserverArrayCallbacks.ts] //// + +=== domObserverArrayCallbacks.ts === +new ResizeObserver(entries => entries[0]); +>ResizeObserver : Symbol(ResizeObserver, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>entries : Symbol(entries, Decl(domObserverArrayCallbacks.ts, 0, 19)) +>entries : Symbol(entries, Decl(domObserverArrayCallbacks.ts, 0, 19)) + +new MutationObserver(records => records.some(record => record.attributeName === "style")); +>MutationObserver : Symbol(MutationObserver, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>records : Symbol(records, Decl(domObserverArrayCallbacks.ts, 1, 21)) +>records.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) +>records : Symbol(records, Decl(domObserverArrayCallbacks.ts, 1, 21)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --)) +>record : Symbol(record, Decl(domObserverArrayCallbacks.ts, 1, 45)) +>record.attributeName : Symbol(MutationRecord.attributeName, Decl(lib.dom.d.ts, --, --)) +>record : Symbol(record, Decl(domObserverArrayCallbacks.ts, 1, 45)) +>attributeName : Symbol(MutationRecord.attributeName, Decl(lib.dom.d.ts, --, --)) + +new IntersectionObserver(entries => entries.forEach(entry => entry.isIntersecting)); +>IntersectionObserver : Symbol(IntersectionObserver, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>entries : Symbol(entries, Decl(domObserverArrayCallbacks.ts, 2, 25)) +>entries.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>entries : Symbol(entries, Decl(domObserverArrayCallbacks.ts, 2, 25)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>entry : Symbol(entry, Decl(domObserverArrayCallbacks.ts, 2, 52)) +>entry.isIntersecting : Symbol(IntersectionObserverEntry.isIntersecting, Decl(lib.dom.d.ts, --, --)) +>entry : Symbol(entry, Decl(domObserverArrayCallbacks.ts, 2, 52)) +>isIntersecting : Symbol(IntersectionObserverEntry.isIntersecting, Decl(lib.dom.d.ts, --, --)) + diff --git a/tsc/testdata/baselines/reference/compiler/domObserverArrayCallbacks.types b/tsc/testdata/baselines/reference/compiler/domObserverArrayCallbacks.types new file mode 100644 index 0000000000000..8613637947dcc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domObserverArrayCallbacks.types @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/domObserverArrayCallbacks.ts] //// + +=== domObserverArrayCallbacks.ts === +new ResizeObserver(entries => entries[0]); +>new ResizeObserver(entries => entries[0]) : ResizeObserver +>ResizeObserver : { new (callback: ResizeObserverCallback): ResizeObserver; prototype: ResizeObserver; } +>entries => entries[0] : (entries: ResizeObserverEntry[]) => ResizeObserverEntry +>entries : ResizeObserverEntry[] +>entries[0] : ResizeObserverEntry +>entries : ResizeObserverEntry[] +>0 : 0 + +new MutationObserver(records => records.some(record => record.attributeName === "style")); +>new MutationObserver(records => records.some(record => record.attributeName === "style")) : MutationObserver +>MutationObserver : { new (callback: MutationCallback): MutationObserver; prototype: MutationObserver; } +>records => records.some(record => record.attributeName === "style") : (records: MutationRecord[]) => boolean +>records : MutationRecord[] +>records.some(record => record.attributeName === "style") : boolean +>records.some : (predicate: (value: MutationRecord, index: number, array: MutationRecord[]) => unknown, thisArg?: any) => boolean +>records : MutationRecord[] +>some : (predicate: (value: MutationRecord, index: number, array: MutationRecord[]) => unknown, thisArg?: any) => boolean +>record => record.attributeName === "style" : (record: MutationRecord) => boolean +>record : MutationRecord +>record.attributeName === "style" : boolean +>record.attributeName : string | null +>record : MutationRecord +>attributeName : string | null +>"style" : "style" + +new IntersectionObserver(entries => entries.forEach(entry => entry.isIntersecting)); +>new IntersectionObserver(entries => entries.forEach(entry => entry.isIntersecting)) : IntersectionObserver +>IntersectionObserver : { new (callback: IntersectionObserverCallback, options?: IntersectionObserverInit): IntersectionObserver; prototype: IntersectionObserver; } +>entries => entries.forEach(entry => entry.isIntersecting) : (entries: IntersectionObserverEntry[]) => void +>entries : IntersectionObserverEntry[] +>entries.forEach(entry => entry.isIntersecting) : void +>entries.forEach : (callbackfn: (value: IntersectionObserverEntry, index: number, array: IntersectionObserverEntry[]) => void, thisArg?: any) => void +>entries : IntersectionObserverEntry[] +>forEach : (callbackfn: (value: IntersectionObserverEntry, index: number, array: IntersectionObserverEntry[]) => void, thisArg?: any) => void +>entry => entry.isIntersecting : (entry: IntersectionObserverEntry) => boolean +>entry : IntersectionObserverEntry +>entry.isIntersecting : boolean +>entry : IntersectionObserverEntry +>isIntersecting : boolean + diff --git a/tsc/testdata/baselines/reference/compiler/domResizeObserverExplicitArrayCallback.js b/tsc/testdata/baselines/reference/compiler/domResizeObserverExplicitArrayCallback.js new file mode 100644 index 0000000000000..b8067ff2130ad --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domResizeObserverExplicitArrayCallback.js @@ -0,0 +1,9 @@ +//// [tests/cases/compiler/domResizeObserverExplicitArrayCallback.ts] //// + +//// [domResizeObserverExplicitArrayCallback.ts] +new ResizeObserver((entries: ResizeObserverEntry[]) => {}); + + +//// [domResizeObserverExplicitArrayCallback.js] +"use strict"; +new ResizeObserver((entries) => { }); diff --git a/tsc/testdata/baselines/reference/compiler/domResizeObserverExplicitArrayCallback.symbols b/tsc/testdata/baselines/reference/compiler/domResizeObserverExplicitArrayCallback.symbols new file mode 100644 index 0000000000000..578821cef86e3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domResizeObserverExplicitArrayCallback.symbols @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/domResizeObserverExplicitArrayCallback.ts] //// + +=== domResizeObserverExplicitArrayCallback.ts === +new ResizeObserver((entries: ResizeObserverEntry[]) => {}); +>ResizeObserver : Symbol(ResizeObserver, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>entries : Symbol(entries, Decl(domResizeObserverExplicitArrayCallback.ts, 0, 20)) +>ResizeObserverEntry : Symbol(ResizeObserverEntry, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + diff --git a/tsc/testdata/baselines/reference/compiler/domResizeObserverExplicitArrayCallback.types b/tsc/testdata/baselines/reference/compiler/domResizeObserverExplicitArrayCallback.types new file mode 100644 index 0000000000000..0ceb30a8c9a5b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domResizeObserverExplicitArrayCallback.types @@ -0,0 +1,9 @@ +//// [tests/cases/compiler/domResizeObserverExplicitArrayCallback.ts] //// + +=== domResizeObserverExplicitArrayCallback.ts === +new ResizeObserver((entries: ResizeObserverEntry[]) => {}); +>new ResizeObserver((entries: ResizeObserverEntry[]) => {}) : ResizeObserver +>ResizeObserver : { new (callback: ResizeObserverCallback): ResizeObserver; prototype: ResizeObserver; } +>(entries: ResizeObserverEntry[]) => {} : (entries: ResizeObserverEntry[]) => void +>entries : ResizeObserverEntry[] + diff --git a/tsc/testdata/baselines/reference/compiler/domTreeWalkerStructuralMock.js b/tsc/testdata/baselines/reference/compiler/domTreeWalkerStructuralMock.js new file mode 100644 index 0000000000000..6a3d0199c6ba0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domTreeWalkerStructuralMock.js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/domTreeWalkerStructuralMock.ts] //// + +//// [domTreeWalkerStructuralMock.ts] +declare class Walker implements TreeWalker { + currentNode: Node; + readonly filter: NodeFilter | null; + readonly root: Node; + readonly whatToShow: number; + firstChild(): Node | null; + lastChild(): Node | null; + nextNode(): Node | null; + nextSibling(): Node | null; + parentNode(): Node | null; + previousNode(): Node | null; + previousSibling(): Node | null; +} + +declare const walker: Walker; +const result: TreeWalker = walker; + + +//// [domTreeWalkerStructuralMock.js] +"use strict"; +const result = walker; diff --git a/tsc/testdata/baselines/reference/compiler/domTreeWalkerStructuralMock.symbols b/tsc/testdata/baselines/reference/compiler/domTreeWalkerStructuralMock.symbols new file mode 100644 index 0000000000000..c7ef322341b1e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domTreeWalkerStructuralMock.symbols @@ -0,0 +1,60 @@ +//// [tests/cases/compiler/domTreeWalkerStructuralMock.ts] //// + +=== domTreeWalkerStructuralMock.ts === +declare class Walker implements TreeWalker { +>Walker : Symbol(Walker, Decl(domTreeWalkerStructuralMock.ts, 0, 0)) +>TreeWalker : Symbol(TreeWalker, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + currentNode: Node; +>currentNode : Symbol(Walker.currentNode, Decl(domTreeWalkerStructuralMock.ts, 0, 44)) +>Node : Symbol(Node, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + readonly filter: NodeFilter | null; +>filter : Symbol(Walker.filter, Decl(domTreeWalkerStructuralMock.ts, 1, 22)) +>NodeFilter : Symbol(NodeFilter, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + readonly root: Node; +>root : Symbol(Walker.root, Decl(domTreeWalkerStructuralMock.ts, 2, 39)) +>Node : Symbol(Node, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + readonly whatToShow: number; +>whatToShow : Symbol(Walker.whatToShow, Decl(domTreeWalkerStructuralMock.ts, 3, 24)) + + firstChild(): Node | null; +>firstChild : Symbol(Walker.firstChild, Decl(domTreeWalkerStructuralMock.ts, 4, 32)) +>Node : Symbol(Node, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + lastChild(): Node | null; +>lastChild : Symbol(Walker.lastChild, Decl(domTreeWalkerStructuralMock.ts, 5, 30)) +>Node : Symbol(Node, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + nextNode(): Node | null; +>nextNode : Symbol(Walker.nextNode, Decl(domTreeWalkerStructuralMock.ts, 6, 29)) +>Node : Symbol(Node, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + nextSibling(): Node | null; +>nextSibling : Symbol(Walker.nextSibling, Decl(domTreeWalkerStructuralMock.ts, 7, 28)) +>Node : Symbol(Node, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + parentNode(): Node | null; +>parentNode : Symbol(Walker.parentNode, Decl(domTreeWalkerStructuralMock.ts, 8, 31)) +>Node : Symbol(Node, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + previousNode(): Node | null; +>previousNode : Symbol(Walker.previousNode, Decl(domTreeWalkerStructuralMock.ts, 9, 30)) +>Node : Symbol(Node, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + previousSibling(): Node | null; +>previousSibling : Symbol(Walker.previousSibling, Decl(domTreeWalkerStructuralMock.ts, 10, 32)) +>Node : Symbol(Node, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +} + +declare const walker: Walker; +>walker : Symbol(walker, Decl(domTreeWalkerStructuralMock.ts, 14, 13)) +>Walker : Symbol(Walker, Decl(domTreeWalkerStructuralMock.ts, 0, 0)) + +const result: TreeWalker = walker; +>result : Symbol(result, Decl(domTreeWalkerStructuralMock.ts, 15, 5)) +>TreeWalker : Symbol(TreeWalker, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>walker : Symbol(walker, Decl(domTreeWalkerStructuralMock.ts, 14, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/domTreeWalkerStructuralMock.types b/tsc/testdata/baselines/reference/compiler/domTreeWalkerStructuralMock.types new file mode 100644 index 0000000000000..4c95e36226e76 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/domTreeWalkerStructuralMock.types @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/domTreeWalkerStructuralMock.ts] //// + +=== domTreeWalkerStructuralMock.ts === +declare class Walker implements TreeWalker { +>Walker : Walker + + currentNode: Node; +>currentNode : Node + + readonly filter: NodeFilter | null; +>filter : NodeFilter | null + + readonly root: Node; +>root : Node + + readonly whatToShow: number; +>whatToShow : number + + firstChild(): Node | null; +>firstChild : () => Node | null + + lastChild(): Node | null; +>lastChild : () => Node | null + + nextNode(): Node | null; +>nextNode : () => Node | null + + nextSibling(): Node | null; +>nextSibling : () => Node | null + + parentNode(): Node | null; +>parentNode : () => Node | null + + previousNode(): Node | null; +>previousNode : () => Node | null + + previousSibling(): Node | null; +>previousSibling : () => Node | null +} + +declare const walker: Walker; +>walker : Walker + +const result: TreeWalker = walker; +>result : TreeWalker +>walker : Walker + diff --git a/tsc/testdata/baselines/reference/compiler/dynamicDeclarationDefault.js b/tsc/testdata/baselines/reference/compiler/dynamicDeclarationDefault.js new file mode 100644 index 0000000000000..bd4eaaad5a044 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/dynamicDeclarationDefault.js @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/dynamicDeclarationDefault.ts] //// + +//// [profiler.d.ts] +declare module "profiler" { + export function start(): void; +} + +//// [main.mts] +const { default: profiler } = await import("profiler"); +profiler.start(); + + +//// [main.mjs] +const { default: profiler } = await import("profiler"); +profiler.start(); +export {}; diff --git a/tsc/testdata/baselines/reference/compiler/dynamicDeclarationDefault.symbols b/tsc/testdata/baselines/reference/compiler/dynamicDeclarationDefault.symbols new file mode 100644 index 0000000000000..f2a5b602c0c35 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/dynamicDeclarationDefault.symbols @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/dynamicDeclarationDefault.ts] //// + +=== profiler.d.ts === +declare module "profiler" { +>"profiler" : Symbol("profiler", Decl(profiler.d.ts, 0, 0)) + + export function start(): void; +>start : Symbol(start, Decl(profiler.d.ts, 0, 27)) +} + +=== main.mts === +const { default: profiler } = await import("profiler"); +>default : Symbol(default) +>profiler : Symbol(profiler, Decl(main.mts, 0, 7)) +>"profiler" : Symbol("profiler", Decl(profiler.d.ts, 0, 0)) + +profiler.start(); +>profiler.start : Symbol(start, Decl(profiler.d.ts, 0, 27)) +>profiler : Symbol(profiler, Decl(main.mts, 0, 7)) +>start : Symbol(start, Decl(profiler.d.ts, 0, 27)) + diff --git a/tsc/testdata/baselines/reference/compiler/dynamicDeclarationDefault.types b/tsc/testdata/baselines/reference/compiler/dynamicDeclarationDefault.types new file mode 100644 index 0000000000000..fbffb73aea1a4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/dynamicDeclarationDefault.types @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/dynamicDeclarationDefault.ts] //// + +=== profiler.d.ts === +declare module "profiler" { +>"profiler" : typeof import("profiler") + + export function start(): void; +>start : () => void +} + +=== main.mts === +const { default: profiler } = await import("profiler"); +>default : any +>profiler : typeof import("profiler") +>await import("profiler") : { start(): void; default: typeof import("profiler"); } +>import("profiler") : Promise<{ start(): void; default: typeof import("profiler"); }> +>"profiler" : "profiler" + +profiler.start(); +>profiler.start() : void +>profiler.start : () => void +>profiler : typeof import("profiler") +>start : () => void + diff --git a/tsc/testdata/baselines/reference/compiler/embeddedNumericCompoundAssignmentAfterExcludedLiterals.js b/tsc/testdata/baselines/reference/compiler/embeddedNumericCompoundAssignmentAfterExcludedLiterals.js new file mode 100644 index 0000000000000..7414734450b32 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/embeddedNumericCompoundAssignmentAfterExcludedLiterals.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts] //// + +//// [embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts] +function ease(value: number, divisor: number) { + if (value === 0) return 0; + value /= divisor; + if (value === 2) return 2; + return Math.pow(2, -10 * (value -= 1)); +} + + +//// [embeddedNumericCompoundAssignmentAfterExcludedLiterals.js] +"use strict"; +function ease(value, divisor) { + if (value === 0) + return 0; + value /= divisor; + if (value === 2) + return 2; + return Math.pow(2, -10 * (value -= 1)); +} diff --git a/tsc/testdata/baselines/reference/compiler/embeddedNumericCompoundAssignmentAfterExcludedLiterals.symbols b/tsc/testdata/baselines/reference/compiler/embeddedNumericCompoundAssignmentAfterExcludedLiterals.symbols new file mode 100644 index 0000000000000..d09e75481c8fa --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/embeddedNumericCompoundAssignmentAfterExcludedLiterals.symbols @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts] //// + +=== embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts === +function ease(value: number, divisor: number) { +>ease : Symbol(ease, Decl(embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts, 0, 0)) +>value : Symbol(value, Decl(embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts, 0, 14)) +>divisor : Symbol(divisor, Decl(embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts, 0, 28)) + + if (value === 0) return 0; +>value : Symbol(value, Decl(embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts, 0, 14)) + + value /= divisor; +>value : Symbol(value, Decl(embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts, 0, 14)) +>divisor : Symbol(divisor, Decl(embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts, 0, 28)) + + if (value === 2) return 2; +>value : Symbol(value, Decl(embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts, 0, 14)) + + return Math.pow(2, -10 * (value -= 1)); +>Math.pow : Symbol(Math.pow, Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2025.float16.d.ts, --, --) ... and 1 more) +>pow : Symbol(Math.pow, Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts, 0, 14)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/embeddedNumericCompoundAssignmentAfterExcludedLiterals.types b/tsc/testdata/baselines/reference/compiler/embeddedNumericCompoundAssignmentAfterExcludedLiterals.types new file mode 100644 index 0000000000000..4dc48c9f792e4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/embeddedNumericCompoundAssignmentAfterExcludedLiterals.types @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts] //// + +=== embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts === +function ease(value: number, divisor: number) { +>ease : (value: number, divisor: number) => number +>value : number +>divisor : number + + if (value === 0) return 0; +>value === 0 : boolean +>value : number +>0 : 0 +>0 : 0 + + value /= divisor; +>value /= divisor : number +>value : number +>divisor : number + + if (value === 2) return 2; +>value === 2 : boolean +>value : number +>2 : 2 +>2 : 2 + + return Math.pow(2, -10 * (value -= 1)); +>Math.pow(2, -10 * (value -= 1)) : number +>Math.pow : (x: number, y: number) => number +>Math : Math +>pow : (x: number, y: number) => number +>2 : 2 +>-10 * (value -= 1) : number +>-10 : -10 +>10 : 10 +>(value -= 1) : number +>value -= 1 : number +>value : number +>1 : 1 +} + diff --git a/tsc/testdata/baselines/reference/compiler/emptyMappedJsxProps.symbols b/tsc/testdata/baselines/reference/compiler/emptyMappedJsxProps.symbols new file mode 100644 index 0000000000000..dd97e12de8c4d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/emptyMappedJsxProps.symbols @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/emptyMappedJsxProps.tsx] //// + +=== emptyMappedJsxProps.tsx === +declare namespace JSX { +>JSX : Symbol(JSX, Decl(emptyMappedJsxProps.tsx, 0, 0)) + + interface Element {} +>Element : Symbol(Element, Decl(emptyMappedJsxProps.tsx, 0, 23)) + + interface ElementAttributesProperty { props: {}; } +>ElementAttributesProperty : Symbol(ElementAttributesProperty, Decl(emptyMappedJsxProps.tsx, 1, 24)) +>props : Symbol(ElementAttributesProperty.props, Decl(emptyMappedJsxProps.tsx, 2, 41)) + + interface ElementChildrenAttribute { children: {}; } +>ElementChildrenAttribute : Symbol(ElementChildrenAttribute, Decl(emptyMappedJsxProps.tsx, 2, 54)) +>children : Symbol(ElementChildrenAttribute.children, Decl(emptyMappedJsxProps.tsx, 3, 40)) + + interface IntrinsicAttributes { key?: string; } +>IntrinsicAttributes : Symbol(IntrinsicAttributes, Decl(emptyMappedJsxProps.tsx, 3, 56)) +>key : Symbol(IntrinsicAttributes.key, Decl(emptyMappedJsxProps.tsx, 4, 35)) +} + +class Component { +>Component : Symbol(Component, Decl(emptyMappedJsxProps.tsx, 5, 1)) + + props: Readonly<{}> = {}; +>props : Symbol(Component.props, Decl(emptyMappedJsxProps.tsx, 7, 17)) +>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --)) +} +content; +>Component : Symbol(Component, Decl(emptyMappedJsxProps.tsx, 5, 1)) +>Component : Symbol(Component, Decl(emptyMappedJsxProps.tsx, 5, 1)) + diff --git a/tsc/testdata/baselines/reference/compiler/emptyMappedJsxProps.types b/tsc/testdata/baselines/reference/compiler/emptyMappedJsxProps.types new file mode 100644 index 0000000000000..675179090750b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/emptyMappedJsxProps.types @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/emptyMappedJsxProps.tsx] //// + +=== emptyMappedJsxProps.tsx === +declare namespace JSX { + interface Element {} + interface ElementAttributesProperty { props: {}; } +>props : {} + + interface ElementChildrenAttribute { children: {}; } +>children : {} + + interface IntrinsicAttributes { key?: string; } +>key : string | undefined +} + +class Component { +>Component : Component + + props: Readonly<{}> = {}; +>props : Readonly<{}> +>{} : {} +} +content; +>content : JSX.Element +>Component : typeof Component +>Component : typeof Component + diff --git a/tsc/testdata/baselines/reference/compiler/emptyMappedParserMetadata.symbols b/tsc/testdata/baselines/reference/compiler/emptyMappedParserMetadata.symbols new file mode 100644 index 0000000000000..62fa4442973b1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/emptyMappedParserMetadata.symbols @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/emptyMappedParserMetadata.ts] //// + +=== emptyMappedParserMetadata.ts === +type ParserName = "babel" | (Pick & { marker?: never }); +>ParserName : Symbol(ParserName, Decl(emptyMappedParserMetadata.ts, 0, 0)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>marker : Symbol(marker, Decl(emptyMappedParserMetadata.ts, 0, 52)) + +declare const customParser: string; +>customParser : Symbol(customParser, Decl(emptyMappedParserMetadata.ts, 2, 13)) + +const parser: ParserName = customParser; +>parser : Symbol(parser, Decl(emptyMappedParserMetadata.ts, 3, 5)) +>ParserName : Symbol(ParserName, Decl(emptyMappedParserMetadata.ts, 0, 0)) +>customParser : Symbol(customParser, Decl(emptyMappedParserMetadata.ts, 2, 13)) + +const svelteParser: ParserName = "svelte"; +>svelteParser : Symbol(svelteParser, Decl(emptyMappedParserMetadata.ts, 4, 5)) +>ParserName : Symbol(ParserName, Decl(emptyMappedParserMetadata.ts, 0, 0)) + diff --git a/tsc/testdata/baselines/reference/compiler/emptyMappedParserMetadata.types b/tsc/testdata/baselines/reference/compiler/emptyMappedParserMetadata.types new file mode 100644 index 0000000000000..3f63bbefe1d3c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/emptyMappedParserMetadata.types @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/emptyMappedParserMetadata.ts] //// + +=== emptyMappedParserMetadata.ts === +type ParserName = "babel" | (Pick & { marker?: never }); +>ParserName : ParserName +>marker : undefined + +declare const customParser: string; +>customParser : string + +const parser: ParserName = customParser; +>parser : ParserName +>customParser : string + +const svelteParser: ParserName = "svelte"; +>svelteParser : ParserName +>"svelte" : "svelte" + diff --git a/tsc/testdata/baselines/reference/compiler/enumPropertyExhaustiveNullableReceiver.js b/tsc/testdata/baselines/reference/compiler/enumPropertyExhaustiveNullableReceiver.js new file mode 100644 index 0000000000000..7f3edaded19f8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/enumPropertyExhaustiveNullableReceiver.js @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/enumPropertyExhaustiveNullableReceiver.ts] //// + +//// [enumPropertyExhaustiveNullableReceiver.ts] +enum NotificationKind { Review, Comment } + +declare function assertNever(value: never): never; + +function notify(notification: { kind: NotificationKind } | null) { + if (notification === null) return; + switch (notification.kind) { + case NotificationKind.Review: return; + case NotificationKind.Comment: return; + default: return assertNever(notification.kind); + } +} + + +//// [enumPropertyExhaustiveNullableReceiver.js] +"use strict"; +var NotificationKind; +(function (NotificationKind) { + NotificationKind[NotificationKind["Review"] = 0] = "Review"; + NotificationKind[NotificationKind["Comment"] = 1] = "Comment"; +})(NotificationKind || (NotificationKind = {})); +function notify(notification) { + if (notification === null) + return; + switch (notification.kind) { + case NotificationKind.Review: return; + case NotificationKind.Comment: return; + default: return assertNever(notification.kind); + } +} diff --git a/tsc/testdata/baselines/reference/compiler/enumPropertyExhaustiveNullableReceiver.symbols b/tsc/testdata/baselines/reference/compiler/enumPropertyExhaustiveNullableReceiver.symbols new file mode 100644 index 0000000000000..3f9767d7a894c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/enumPropertyExhaustiveNullableReceiver.symbols @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/enumPropertyExhaustiveNullableReceiver.ts] //// + +=== enumPropertyExhaustiveNullableReceiver.ts === +enum NotificationKind { Review, Comment } +>NotificationKind : Symbol(NotificationKind, Decl(enumPropertyExhaustiveNullableReceiver.ts, 0, 0)) +>Review : Symbol(NotificationKind.Review, Decl(enumPropertyExhaustiveNullableReceiver.ts, 0, 23)) +>Comment : Symbol(NotificationKind.Comment, Decl(enumPropertyExhaustiveNullableReceiver.ts, 0, 31)) + +declare function assertNever(value: never): never; +>assertNever : Symbol(assertNever, Decl(enumPropertyExhaustiveNullableReceiver.ts, 0, 41)) +>value : Symbol(value, Decl(enumPropertyExhaustiveNullableReceiver.ts, 2, 29)) + +function notify(notification: { kind: NotificationKind } | null) { +>notify : Symbol(notify, Decl(enumPropertyExhaustiveNullableReceiver.ts, 2, 50)) +>notification : Symbol(notification, Decl(enumPropertyExhaustiveNullableReceiver.ts, 4, 16)) +>kind : Symbol(kind, Decl(enumPropertyExhaustiveNullableReceiver.ts, 4, 31)) +>NotificationKind : Symbol(NotificationKind, Decl(enumPropertyExhaustiveNullableReceiver.ts, 0, 0)) + + if (notification === null) return; +>notification : Symbol(notification, Decl(enumPropertyExhaustiveNullableReceiver.ts, 4, 16)) + + switch (notification.kind) { +>notification.kind : Symbol(kind, Decl(enumPropertyExhaustiveNullableReceiver.ts, 4, 31)) +>notification : Symbol(notification, Decl(enumPropertyExhaustiveNullableReceiver.ts, 4, 16)) +>kind : Symbol(kind, Decl(enumPropertyExhaustiveNullableReceiver.ts, 4, 31)) + + case NotificationKind.Review: return; +>NotificationKind.Review : Symbol(NotificationKind.Review, Decl(enumPropertyExhaustiveNullableReceiver.ts, 0, 23)) +>NotificationKind : Symbol(NotificationKind, Decl(enumPropertyExhaustiveNullableReceiver.ts, 0, 0)) +>Review : Symbol(NotificationKind.Review, Decl(enumPropertyExhaustiveNullableReceiver.ts, 0, 23)) + + case NotificationKind.Comment: return; +>NotificationKind.Comment : Symbol(NotificationKind.Comment, Decl(enumPropertyExhaustiveNullableReceiver.ts, 0, 31)) +>NotificationKind : Symbol(NotificationKind, Decl(enumPropertyExhaustiveNullableReceiver.ts, 0, 0)) +>Comment : Symbol(NotificationKind.Comment, Decl(enumPropertyExhaustiveNullableReceiver.ts, 0, 31)) + + default: return assertNever(notification.kind); +>assertNever : Symbol(assertNever, Decl(enumPropertyExhaustiveNullableReceiver.ts, 0, 41)) +>notification.kind : Symbol(kind, Decl(enumPropertyExhaustiveNullableReceiver.ts, 4, 31)) +>notification : Symbol(notification, Decl(enumPropertyExhaustiveNullableReceiver.ts, 4, 16)) +>kind : Symbol(kind, Decl(enumPropertyExhaustiveNullableReceiver.ts, 4, 31)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/enumPropertyExhaustiveNullableReceiver.types b/tsc/testdata/baselines/reference/compiler/enumPropertyExhaustiveNullableReceiver.types new file mode 100644 index 0000000000000..6bfd58dbc6a0a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/enumPropertyExhaustiveNullableReceiver.types @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/enumPropertyExhaustiveNullableReceiver.ts] //// + +=== enumPropertyExhaustiveNullableReceiver.ts === +enum NotificationKind { Review, Comment } +>NotificationKind : NotificationKind +>Review : NotificationKind.Review +>Comment : NotificationKind.Comment + +declare function assertNever(value: never): never; +>assertNever : (value: never) => never +>value : never + +function notify(notification: { kind: NotificationKind } | null) { +>notify : (notification: { kind: NotificationKind; } | null) => undefined +>notification : { kind: NotificationKind; } | null +>kind : NotificationKind + + if (notification === null) return; +>notification === null : boolean +>notification : { kind: NotificationKind; } | null + + switch (notification.kind) { +>notification.kind : NotificationKind +>notification : { kind: NotificationKind; } +>kind : NotificationKind + + case NotificationKind.Review: return; +>NotificationKind.Review : NotificationKind.Review +>NotificationKind : typeof NotificationKind +>Review : NotificationKind.Review + + case NotificationKind.Comment: return; +>NotificationKind.Comment : NotificationKind.Comment +>NotificationKind : typeof NotificationKind +>Comment : NotificationKind.Comment + + default: return assertNever(notification.kind); +>assertNever(notification.kind) : never +>assertNever : (value: never) => never +>notification.kind : never +>notification : { kind: NotificationKind; } +>kind : never + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/excludedNumericLiteralAfterDecrement.js b/tsc/testdata/baselines/reference/compiler/excludedNumericLiteralAfterDecrement.js new file mode 100644 index 0000000000000..cfdd6a0491ed4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/excludedNumericLiteralAfterDecrement.js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/excludedNumericLiteralAfterDecrement.ts] //// + +//// [excludedNumericLiteralAfterDecrement.ts] +function decrement(count: number) { + if (count === 0) return; + count--; + if (count === 0) return; +} + + +//// [excludedNumericLiteralAfterDecrement.js] +"use strict"; +function decrement(count) { + if (count === 0) + return; + count--; + if (count === 0) + return; +} diff --git a/tsc/testdata/baselines/reference/compiler/excludedNumericLiteralAfterDecrement.symbols b/tsc/testdata/baselines/reference/compiler/excludedNumericLiteralAfterDecrement.symbols new file mode 100644 index 0000000000000..5cf5b75db2270 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/excludedNumericLiteralAfterDecrement.symbols @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/excludedNumericLiteralAfterDecrement.ts] //// + +=== excludedNumericLiteralAfterDecrement.ts === +function decrement(count: number) { +>decrement : Symbol(decrement, Decl(excludedNumericLiteralAfterDecrement.ts, 0, 0)) +>count : Symbol(count, Decl(excludedNumericLiteralAfterDecrement.ts, 0, 19)) + + if (count === 0) return; +>count : Symbol(count, Decl(excludedNumericLiteralAfterDecrement.ts, 0, 19)) + + count--; +>count : Symbol(count, Decl(excludedNumericLiteralAfterDecrement.ts, 0, 19)) + + if (count === 0) return; +>count : Symbol(count, Decl(excludedNumericLiteralAfterDecrement.ts, 0, 19)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/excludedNumericLiteralAfterDecrement.types b/tsc/testdata/baselines/reference/compiler/excludedNumericLiteralAfterDecrement.types new file mode 100644 index 0000000000000..7a3d3f9e4ad78 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/excludedNumericLiteralAfterDecrement.types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/excludedNumericLiteralAfterDecrement.ts] //// + +=== excludedNumericLiteralAfterDecrement.ts === +function decrement(count: number) { +>decrement : (count: number) => void +>count : number + + if (count === 0) return; +>count === 0 : boolean +>count : number +>0 : 0 + + count--; +>count-- : number +>count : number + + if (count === 0) return; +>count === 0 : boolean +>count : number +>0 : 0 +} + diff --git a/tsc/testdata/baselines/reference/compiler/fetchContextualRequestUrl.symbols b/tsc/testdata/baselines/reference/compiler/fetchContextualRequestUrl.symbols new file mode 100644 index 0000000000000..3b3293fa12bdb --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fetchContextualRequestUrl.symbols @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/fetchContextualRequestUrl.ts] //// + +=== fetchContextualRequestUrl.ts === +const fetchUsingRequestUrl: typeof fetch = async input => { +>fetchUsingRequestUrl : Symbol(fetchUsingRequestUrl, Decl(fetchContextualRequestUrl.ts, 0, 5)) +>fetch : Symbol(fetch, Decl(lib.dom.d.ts, --, --)) +>input : Symbol(input, Decl(fetchContextualRequestUrl.ts, 0, 48)) + + const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url; +>url : Symbol(url, Decl(fetchContextualRequestUrl.ts, 1, 9)) +>input : Symbol(input, Decl(fetchContextualRequestUrl.ts, 0, 48)) +>input : Symbol(input, Decl(fetchContextualRequestUrl.ts, 0, 48)) +>input : Symbol(input, Decl(fetchContextualRequestUrl.ts, 0, 48)) +>URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>input.href : Symbol(URL.href, Decl(lib.dom.d.ts, --, --)) +>input : Symbol(input, Decl(fetchContextualRequestUrl.ts, 0, 48)) +>href : Symbol(URL.href, Decl(lib.dom.d.ts, --, --)) +>input.url : Symbol(Request.url, Decl(lib.dom.d.ts, --, --)) +>input : Symbol(input, Decl(fetchContextualRequestUrl.ts, 0, 48)) +>url : Symbol(Request.url, Decl(lib.dom.d.ts, --, --)) + + return new Response(url); +>Response : Symbol(Response, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>url : Symbol(url, Decl(fetchContextualRequestUrl.ts, 1, 9)) + +}; + diff --git a/tsc/testdata/baselines/reference/compiler/fetchContextualRequestUrl.types b/tsc/testdata/baselines/reference/compiler/fetchContextualRequestUrl.types new file mode 100644 index 0000000000000..f22b259a12191 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fetchContextualRequestUrl.types @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/fetchContextualRequestUrl.ts] //// + +=== fetchContextualRequestUrl.ts === +const fetchUsingRequestUrl: typeof fetch = async input => { +>fetchUsingRequestUrl : (input: RequestInfo | URL, init?: RequestInit) => Promise +>fetch : (input: RequestInfo | URL, init?: RequestInit) => Promise +>async input => { const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url; return new Response(url);} : (input: URL | RequestInfo) => Promise +>input : URL | RequestInfo + + const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url; +>url : string +>typeof input === "string" ? input : input instanceof URL ? input.href : input.url : string +>typeof input === "string" : boolean +>typeof input : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" +>input : URL | RequestInfo +>"string" : "string" +>input : string +>input instanceof URL ? input.href : input.url : string +>input instanceof URL : boolean +>input : Request | URL +>URL : { new (url: string | URL, base?: string | URL): URL; prototype: URL; canParse(url: string | URL, base?: string | URL): boolean; createObjectURL(obj: Blob | MediaSource): string; parse(url: string | URL, base?: string | URL): URL | null; revokeObjectURL(url: string): void; } +>input.href : string +>input : URL +>href : string +>input.url : string +>input : Request +>url : string + + return new Response(url); +>new Response(url) : Response +>Response : { new (body?: BodyInit | null, init?: ResponseInit): Response; prototype: Response; error(): Response; json(data: any, init?: ResponseInit): Response; redirect(url: string | URL, status?: number): Response; } +>url : string + +}; + diff --git a/tsc/testdata/baselines/reference/compiler/fetchOverloadCallableCopy.symbols b/tsc/testdata/baselines/reference/compiler/fetchOverloadCallableCopy.symbols new file mode 100644 index 0000000000000..76988e0bdb5d8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fetchOverloadCallableCopy.symbols @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/fetchOverloadCallableCopy.ts] //// + +=== fetchOverloadCallableCopy.ts === +declare function fetch(input: RequestInfo | URL, init?: RequestInit): Promise; +>fetch : Symbol(fetch, Decl(lib.dom.d.ts, --, --), Decl(fetchOverloadCallableCopy.ts, 0, 0)) +>input : Symbol(input, Decl(fetchOverloadCallableCopy.ts, 0, 23)) +>RequestInfo : Symbol(RequestInfo, Decl(lib.dom.d.ts, --, --)) +>URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>init : Symbol(init, Decl(fetchOverloadCallableCopy.ts, 0, 48)) +>RequestInit : Symbol(RequestInit, Decl(lib.dom.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>Response : Symbol(Response, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +type CallableCopy unknown> = (...args: Parameters) => ReturnType; +>CallableCopy : Symbol(CallableCopy, Decl(fetchOverloadCallableCopy.ts, 0, 88)) +>T : Symbol(T, Decl(fetchOverloadCallableCopy.ts, 1, 18)) +>args : Symbol(args, Decl(fetchOverloadCallableCopy.ts, 1, 29)) +>args : Symbol(args, Decl(fetchOverloadCallableCopy.ts, 1, 62)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(fetchOverloadCallableCopy.ts, 1, 18)) +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(fetchOverloadCallableCopy.ts, 1, 18)) + +declare const copiedFetch: CallableCopy; +>copiedFetch : Symbol(copiedFetch, Decl(fetchOverloadCallableCopy.ts, 2, 13)) +>CallableCopy : Symbol(CallableCopy, Decl(fetchOverloadCallableCopy.ts, 0, 88)) +>fetch : Symbol(fetch, Decl(lib.dom.d.ts, --, --), Decl(fetchOverloadCallableCopy.ts, 0, 0)) + +const replacementFetch: typeof fetch = copiedFetch; +>replacementFetch : Symbol(replacementFetch, Decl(fetchOverloadCallableCopy.ts, 3, 5)) +>fetch : Symbol(fetch, Decl(lib.dom.d.ts, --, --), Decl(fetchOverloadCallableCopy.ts, 0, 0)) +>copiedFetch : Symbol(copiedFetch, Decl(fetchOverloadCallableCopy.ts, 2, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/fetchOverloadCallableCopy.types b/tsc/testdata/baselines/reference/compiler/fetchOverloadCallableCopy.types new file mode 100644 index 0000000000000..faf620e772fd8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fetchOverloadCallableCopy.types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/fetchOverloadCallableCopy.ts] //// + +=== fetchOverloadCallableCopy.ts === +declare function fetch(input: RequestInfo | URL, init?: RequestInit): Promise; +>fetch : { (input: RequestInfo | URL, init?: RequestInit): Promise; (input: RequestInfo | URL, init?: RequestInit): Promise; } +>input : URL | RequestInfo +>init : RequestInit | undefined + +type CallableCopy unknown> = (...args: Parameters) => ReturnType; +>CallableCopy : CallableCopy +>args : never[] +>args : Parameters + +declare const copiedFetch: CallableCopy; +>copiedFetch : CallableCopy<{ (input: RequestInfo | URL, init?: RequestInit): Promise; (input: RequestInfo | URL, init?: RequestInit): Promise; }> +>fetch : { (input: RequestInfo | URL, init?: RequestInit): Promise; (input: RequestInfo | URL, init?: RequestInit): Promise; } + +const replacementFetch: typeof fetch = copiedFetch; +>replacementFetch : { (input: RequestInfo | URL, init?: RequestInit): Promise; (input: RequestInfo | URL, init?: RequestInit): Promise; } +>fetch : { (input: RequestInfo | URL, init?: RequestInit): Promise; (input: RequestInfo | URL, init?: RequestInit): Promise; } +>copiedFetch : CallableCopy<{ (input: RequestInfo | URL, init?: RequestInit): Promise; (input: RequestInfo | URL, init?: RequestInit): Promise; }> + diff --git a/tsc/testdata/baselines/reference/compiler/fetchReplacementInputCompatibility.symbols b/tsc/testdata/baselines/reference/compiler/fetchReplacementInputCompatibility.symbols new file mode 100644 index 0000000000000..4930c095e7e3d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fetchReplacementInputCompatibility.symbols @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/fetchReplacementInputCompatibility.ts] //// + +=== fetchReplacementInputCompatibility.ts === +declare const fetchReplacement: (input: string | URL | Request, init?: RequestInit) => Promise; +>fetchReplacement : Symbol(fetchReplacement, Decl(fetchReplacementInputCompatibility.ts, 0, 13)) +>input : Symbol(input, Decl(fetchReplacementInputCompatibility.ts, 0, 33)) +>URL : Symbol(URL, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>Request : Symbol(Request, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>init : Symbol(init, Decl(fetchReplacementInputCompatibility.ts, 0, 63)) +>RequestInit : Symbol(RequestInit, Decl(lib.dom.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>Response : Symbol(Response, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +const replacement: typeof fetch = fetchReplacement; +>replacement : Symbol(replacement, Decl(fetchReplacementInputCompatibility.ts, 1, 5)) +>fetch : Symbol(fetch, Decl(lib.dom.d.ts, --, --)) +>fetchReplacement : Symbol(fetchReplacement, Decl(fetchReplacementInputCompatibility.ts, 0, 13)) + +declare const input: Parameters[0]; +>input : Symbol(input, Decl(fetchReplacementInputCompatibility.ts, 3, 13)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>fetch : Symbol(fetch, Decl(lib.dom.d.ts, --, --)) + +fetchReplacement(input); +>fetchReplacement : Symbol(fetchReplacement, Decl(fetchReplacementInputCompatibility.ts, 0, 13)) +>input : Symbol(input, Decl(fetchReplacementInputCompatibility.ts, 3, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/fetchReplacementInputCompatibility.types b/tsc/testdata/baselines/reference/compiler/fetchReplacementInputCompatibility.types new file mode 100644 index 0000000000000..cd8a377e15001 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/fetchReplacementInputCompatibility.types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/fetchReplacementInputCompatibility.ts] //// + +=== fetchReplacementInputCompatibility.ts === +declare const fetchReplacement: (input: string | URL | Request, init?: RequestInit) => Promise; +>fetchReplacement : (input: string | URL | Request, init?: RequestInit) => Promise +>input : string | Request | URL +>init : RequestInit | undefined + +const replacement: typeof fetch = fetchReplacement; +>replacement : (input: RequestInfo | URL, init?: RequestInit) => Promise +>fetch : (input: RequestInfo | URL, init?: RequestInit) => Promise +>fetchReplacement : (input: string | URL | Request, init?: RequestInit) => Promise + +declare const input: Parameters[0]; +>input : URL | RequestInfo +>fetch : (input: RequestInfo | URL, init?: RequestInit) => Promise + +fetchReplacement(input); +>fetchReplacement(input) : Promise +>fetchReplacement : (input: string | URL | Request, init?: RequestInit) => Promise +>input : URL | RequestInfo + diff --git a/tsc/testdata/baselines/reference/compiler/genericCallInNegativeTypeofBranch.js b/tsc/testdata/baselines/reference/compiler/genericCallInNegativeTypeofBranch.js new file mode 100644 index 0000000000000..60ced5af62d05 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/genericCallInNegativeTypeofBranch.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/genericCallInNegativeTypeofBranch.ts] //// + +//// [genericCallInNegativeTypeofBranch.ts] +declare function identity(value: T): T; +function normalize(value: unknown) { + return typeof value === "string" ? value : identity(value); +} + + +//// [genericCallInNegativeTypeofBranch.js] +"use strict"; +function normalize(value) { + return typeof value === "string" ? value : identity(value); +} diff --git a/tsc/testdata/baselines/reference/compiler/genericCallInNegativeTypeofBranch.symbols b/tsc/testdata/baselines/reference/compiler/genericCallInNegativeTypeofBranch.symbols new file mode 100644 index 0000000000000..46129c3d630f9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/genericCallInNegativeTypeofBranch.symbols @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/genericCallInNegativeTypeofBranch.ts] //// + +=== genericCallInNegativeTypeofBranch.ts === +declare function identity(value: T): T; +>identity : Symbol(identity, Decl(genericCallInNegativeTypeofBranch.ts, 0, 0)) +>T : Symbol(T, Decl(genericCallInNegativeTypeofBranch.ts, 0, 26)) +>value : Symbol(value, Decl(genericCallInNegativeTypeofBranch.ts, 0, 29)) +>T : Symbol(T, Decl(genericCallInNegativeTypeofBranch.ts, 0, 26)) +>T : Symbol(T, Decl(genericCallInNegativeTypeofBranch.ts, 0, 26)) + +function normalize(value: unknown) { +>normalize : Symbol(normalize, Decl(genericCallInNegativeTypeofBranch.ts, 0, 42)) +>value : Symbol(value, Decl(genericCallInNegativeTypeofBranch.ts, 1, 19)) + + return typeof value === "string" ? value : identity(value); +>value : Symbol(value, Decl(genericCallInNegativeTypeofBranch.ts, 1, 19)) +>value : Symbol(value, Decl(genericCallInNegativeTypeofBranch.ts, 1, 19)) +>identity : Symbol(identity, Decl(genericCallInNegativeTypeofBranch.ts, 0, 0)) +>value : Symbol(value, Decl(genericCallInNegativeTypeofBranch.ts, 1, 19)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/genericCallInNegativeTypeofBranch.types b/tsc/testdata/baselines/reference/compiler/genericCallInNegativeTypeofBranch.types new file mode 100644 index 0000000000000..d057373eefd39 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/genericCallInNegativeTypeofBranch.types @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/genericCallInNegativeTypeofBranch.ts] //// + +=== genericCallInNegativeTypeofBranch.ts === +declare function identity(value: T): T; +>identity : (value: T) => T +>value : T + +function normalize(value: unknown) { +>normalize : (value: unknown) => unknown +>value : unknown + + return typeof value === "string" ? value : identity(value); +>typeof value === "string" ? value : identity(value) : unknown +>typeof value === "string" : boolean +>typeof value : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" +>value : unknown +>"string" : "string" +>value : string +>identity(value) : unknown +>identity : (value: T) => T +>value : unknown +} + diff --git a/tsc/testdata/baselines/reference/compiler/genericContextualComposition.js b/tsc/testdata/baselines/reference/compiler/genericContextualComposition.js new file mode 100644 index 0000000000000..e94f45b3a0fe2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/genericContextualComposition.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/genericContextualComposition.ts] //// + +//// [genericContextualComposition.ts] +type Enhancer = (next: Next) => Next & Extension; +declare function compose(first: (value: A) => Result, second: (...args: Args) => A): (...args: Args) => Result; +declare function compose(...functions: Function[]): (...args: any[]) => Result; +declare const instrument: Enhancer<{ extra: unknown }>, persist: Enhancer; +const enhancer: Enhancer = compose(instrument, persist); + + +//// [genericContextualComposition.js] +"use strict"; +const enhancer = compose(instrument, persist); diff --git a/tsc/testdata/baselines/reference/compiler/genericContextualComposition.symbols b/tsc/testdata/baselines/reference/compiler/genericContextualComposition.symbols new file mode 100644 index 0000000000000..630b5db1840b7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/genericContextualComposition.symbols @@ -0,0 +1,51 @@ +//// [tests/cases/compiler/genericContextualComposition.ts] //// + +=== genericContextualComposition.ts === +type Enhancer = (next: Next) => Next & Extension; +>Enhancer : Symbol(Enhancer, Decl(genericContextualComposition.ts, 0, 0)) +>Extension : Symbol(Extension, Decl(genericContextualComposition.ts, 0, 14)) +>Next : Symbol(Next, Decl(genericContextualComposition.ts, 0, 44)) +>next : Symbol(next, Decl(genericContextualComposition.ts, 0, 61)) +>Next : Symbol(Next, Decl(genericContextualComposition.ts, 0, 44)) +>Next : Symbol(Next, Decl(genericContextualComposition.ts, 0, 44)) +>Extension : Symbol(Extension, Decl(genericContextualComposition.ts, 0, 14)) + +declare function compose(first: (value: A) => Result, second: (...args: Args) => A): (...args: Args) => Result; +>compose : Symbol(compose, Decl(genericContextualComposition.ts, 0, 93), Decl(genericContextualComposition.ts, 1, 142)) +>A : Symbol(A, Decl(genericContextualComposition.ts, 1, 25)) +>Args : Symbol(Args, Decl(genericContextualComposition.ts, 1, 27)) +>Result : Symbol(Result, Decl(genericContextualComposition.ts, 1, 47)) +>first : Symbol(first, Decl(genericContextualComposition.ts, 1, 56)) +>value : Symbol(value, Decl(genericContextualComposition.ts, 1, 64)) +>A : Symbol(A, Decl(genericContextualComposition.ts, 1, 25)) +>Result : Symbol(Result, Decl(genericContextualComposition.ts, 1, 47)) +>second : Symbol(second, Decl(genericContextualComposition.ts, 1, 84)) +>args : Symbol(args, Decl(genericContextualComposition.ts, 1, 94)) +>Args : Symbol(Args, Decl(genericContextualComposition.ts, 1, 27)) +>A : Symbol(A, Decl(genericContextualComposition.ts, 1, 25)) +>args : Symbol(args, Decl(genericContextualComposition.ts, 1, 117)) +>Args : Symbol(Args, Decl(genericContextualComposition.ts, 1, 27)) +>Result : Symbol(Result, Decl(genericContextualComposition.ts, 1, 47)) + +declare function compose(...functions: Function[]): (...args: any[]) => Result; +>compose : Symbol(compose, Decl(genericContextualComposition.ts, 0, 93), Decl(genericContextualComposition.ts, 1, 142)) +>Result : Symbol(Result, Decl(genericContextualComposition.ts, 2, 25)) +>functions : Symbol(functions, Decl(genericContextualComposition.ts, 2, 33)) +>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>args : Symbol(args, Decl(genericContextualComposition.ts, 2, 61)) +>Result : Symbol(Result, Decl(genericContextualComposition.ts, 2, 25)) + +declare const instrument: Enhancer<{ extra: unknown }>, persist: Enhancer; +>instrument : Symbol(instrument, Decl(genericContextualComposition.ts, 3, 13)) +>Enhancer : Symbol(Enhancer, Decl(genericContextualComposition.ts, 0, 0)) +>extra : Symbol(extra, Decl(genericContextualComposition.ts, 3, 36)) +>persist : Symbol(persist, Decl(genericContextualComposition.ts, 3, 55)) +>Enhancer : Symbol(Enhancer, Decl(genericContextualComposition.ts, 0, 0)) + +const enhancer: Enhancer = compose(instrument, persist); +>enhancer : Symbol(enhancer, Decl(genericContextualComposition.ts, 4, 5)) +>Enhancer : Symbol(Enhancer, Decl(genericContextualComposition.ts, 0, 0)) +>compose : Symbol(compose, Decl(genericContextualComposition.ts, 0, 93), Decl(genericContextualComposition.ts, 1, 142)) +>instrument : Symbol(instrument, Decl(genericContextualComposition.ts, 3, 13)) +>persist : Symbol(persist, Decl(genericContextualComposition.ts, 3, 55)) + diff --git a/tsc/testdata/baselines/reference/compiler/genericContextualComposition.types b/tsc/testdata/baselines/reference/compiler/genericContextualComposition.types new file mode 100644 index 0000000000000..c240cc68f21f9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/genericContextualComposition.types @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/genericContextualComposition.ts] //// + +=== genericContextualComposition.ts === +type Enhancer = (next: Next) => Next & Extension; +>Enhancer : Enhancer +>next : Next + +declare function compose(first: (value: A) => Result, second: (...args: Args) => A): (...args: Args) => Result; +>compose : { (first: (value: A) => Result, second: (...args: Args) => A): (...args: Args) => Result; (...functions: Function[]): (...args: any[]) => Result_1; } +>first : (value: A) => Result +>value : A +>second : (...args: Args) => A +>args : Args +>args : Args + +declare function compose(...functions: Function[]): (...args: any[]) => Result; +>compose : { (first: (value: A) => Result_1, second: (...args: Args) => A): (...args: Args) => Result_1; (...functions: Function[]): (...args: any[]) => Result; } +>functions : Function[] +>args : any[] + +declare const instrument: Enhancer<{ extra: unknown }>, persist: Enhancer; +>instrument : Enhancer<{ extra: unknown; }> +>extra : unknown +>persist : Enhancer<{}> + +const enhancer: Enhancer = compose(instrument, persist); +>enhancer : Enhancer<{}> +>compose(instrument, persist) : (...args: any[]) => Next +>compose : { (first: (value: A) => Result, second: (...args: Args) => A): (...args: Args) => Result; (...functions: Function[]): (...args: any[]) => Result; } +>instrument : Enhancer<{ extra: unknown; }> +>persist : Enhancer<{}> + diff --git a/tsc/testdata/baselines/reference/compiler/genericValueMarker.symbols b/tsc/testdata/baselines/reference/compiler/genericValueMarker.symbols new file mode 100644 index 0000000000000..b2ff90d724129 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/genericValueMarker.symbols @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/genericValueMarker.ts] //// + +=== genericValueMarker.ts === +declare const valueMarker: unique symbol; +>valueMarker : Symbol(valueMarker, Decl(genericValueMarker.ts, 0, 13)) + +type AnyValue = { [valueMarker]?: undefined } | number; +>AnyValue : Symbol(AnyValue, Decl(genericValueMarker.ts, 0, 41)) +>[valueMarker] : Symbol([valueMarker], Decl(genericValueMarker.ts, 1, 17)) +>valueMarker : Symbol(valueMarker, Decl(genericValueMarker.ts, 0, 13)) + +declare function compare(value: Value & AnyValue): void; +>compare : Symbol(compare, Decl(genericValueMarker.ts, 1, 55)) +>Value : Symbol(Value, Decl(genericValueMarker.ts, 2, 25)) +>value : Symbol(value, Decl(genericValueMarker.ts, 2, 32)) +>Value : Symbol(Value, Decl(genericValueMarker.ts, 2, 25)) +>AnyValue : Symbol(AnyValue, Decl(genericValueMarker.ts, 0, 41)) + +compare((): number => 0); +>compare : Symbol(compare, Decl(genericValueMarker.ts, 1, 55)) + diff --git a/tsc/testdata/baselines/reference/compiler/genericValueMarker.types b/tsc/testdata/baselines/reference/compiler/genericValueMarker.types new file mode 100644 index 0000000000000..bf712a49552cf --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/genericValueMarker.types @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/genericValueMarker.ts] //// + +=== genericValueMarker.ts === +declare const valueMarker: unique symbol; +>valueMarker : unique symbol + +type AnyValue = { [valueMarker]?: undefined } | number; +>AnyValue : AnyValue +>[valueMarker] : undefined +>valueMarker : unique symbol + +declare function compare(value: Value & AnyValue): void; +>compare : (value: Value & AnyValue) => void +>value : Value & AnyValue + +compare((): number => 0); +>compare((): number => 0) : void +>compare : (value: Value & AnyValue) => void +>(): number => 0 : () => number +>0 : 0 + diff --git a/tsc/testdata/baselines/reference/compiler/identityOfInstantiatedMappedIntersection.js b/tsc/testdata/baselines/reference/compiler/identityOfInstantiatedMappedIntersection.js new file mode 100644 index 0000000000000..26394af1edfe4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/identityOfInstantiatedMappedIntersection.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/identityOfInstantiatedMappedIntersection.ts] //// + +//// [identityOfInstantiatedMappedIntersection.ts] +declare const brand: unique symbol; +type Equal = (() => V extends T ? 1 : 2) extends (() => V extends U ? 1 : 2) ? true : false; +declare function assertEqual(value: Equal): void; + +type Flatten = { [K in keyof T]: T[K] }; +type Branded = Flatten<{ name: string }> & { [brand]: { label: true } }; +assertEqual(true); + + +//// [identityOfInstantiatedMappedIntersection.js] +"use strict"; +assertEqual(true); diff --git a/tsc/testdata/baselines/reference/compiler/identityOfInstantiatedMappedIntersection.symbols b/tsc/testdata/baselines/reference/compiler/identityOfInstantiatedMappedIntersection.symbols new file mode 100644 index 0000000000000..b3a19b1982e83 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/identityOfInstantiatedMappedIntersection.symbols @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/identityOfInstantiatedMappedIntersection.ts] //// + +=== identityOfInstantiatedMappedIntersection.ts === +declare const brand: unique symbol; +>brand : Symbol(brand, Decl(identityOfInstantiatedMappedIntersection.ts, 0, 13)) + +type Equal = (() => V extends T ? 1 : 2) extends (() => V extends U ? 1 : 2) ? true : false; +>Equal : Symbol(Equal, Decl(identityOfInstantiatedMappedIntersection.ts, 0, 35)) +>T : Symbol(T, Decl(identityOfInstantiatedMappedIntersection.ts, 1, 11)) +>U : Symbol(U, Decl(identityOfInstantiatedMappedIntersection.ts, 1, 13)) +>V : Symbol(V, Decl(identityOfInstantiatedMappedIntersection.ts, 1, 21)) +>V : Symbol(V, Decl(identityOfInstantiatedMappedIntersection.ts, 1, 21)) +>T : Symbol(T, Decl(identityOfInstantiatedMappedIntersection.ts, 1, 11)) +>V : Symbol(V, Decl(identityOfInstantiatedMappedIntersection.ts, 1, 60)) +>V : Symbol(V, Decl(identityOfInstantiatedMappedIntersection.ts, 1, 60)) +>U : Symbol(U, Decl(identityOfInstantiatedMappedIntersection.ts, 1, 13)) + +declare function assertEqual(value: Equal): void; +>assertEqual : Symbol(assertEqual, Decl(identityOfInstantiatedMappedIntersection.ts, 1, 104)) +>T : Symbol(T, Decl(identityOfInstantiatedMappedIntersection.ts, 2, 29)) +>U : Symbol(U, Decl(identityOfInstantiatedMappedIntersection.ts, 2, 31)) +>value : Symbol(value, Decl(identityOfInstantiatedMappedIntersection.ts, 2, 35)) +>Equal : Symbol(Equal, Decl(identityOfInstantiatedMappedIntersection.ts, 0, 35)) +>T : Symbol(T, Decl(identityOfInstantiatedMappedIntersection.ts, 2, 29)) +>U : Symbol(U, Decl(identityOfInstantiatedMappedIntersection.ts, 2, 31)) + +type Flatten = { [K in keyof T]: T[K] }; +>Flatten : Symbol(Flatten, Decl(identityOfInstantiatedMappedIntersection.ts, 2, 61)) +>T : Symbol(T, Decl(identityOfInstantiatedMappedIntersection.ts, 4, 13)) +>K : Symbol(K, Decl(identityOfInstantiatedMappedIntersection.ts, 4, 21)) +>T : Symbol(T, Decl(identityOfInstantiatedMappedIntersection.ts, 4, 13)) +>T : Symbol(T, Decl(identityOfInstantiatedMappedIntersection.ts, 4, 13)) +>K : Symbol(K, Decl(identityOfInstantiatedMappedIntersection.ts, 4, 21)) + +type Branded = Flatten<{ name: string }> & { [brand]: { label: true } }; +>Branded : Symbol(Branded, Decl(identityOfInstantiatedMappedIntersection.ts, 4, 43)) +>Flatten : Symbol(Flatten, Decl(identityOfInstantiatedMappedIntersection.ts, 2, 61)) +>name : Symbol(name, Decl(identityOfInstantiatedMappedIntersection.ts, 5, 24)) +>[brand] : Symbol([brand], Decl(identityOfInstantiatedMappedIntersection.ts, 5, 44)) +>brand : Symbol(brand, Decl(identityOfInstantiatedMappedIntersection.ts, 0, 13)) +>label : Symbol(label, Decl(identityOfInstantiatedMappedIntersection.ts, 5, 55)) + +assertEqual(true); +>assertEqual : Symbol(assertEqual, Decl(identityOfInstantiatedMappedIntersection.ts, 1, 104)) +>Branded : Symbol(Branded, Decl(identityOfInstantiatedMappedIntersection.ts, 4, 43)) +>name : Symbol(name, Decl(identityOfInstantiatedMappedIntersection.ts, 6, 22)) +>[brand] : Symbol([brand], Decl(identityOfInstantiatedMappedIntersection.ts, 6, 41)) +>brand : Symbol(brand, Decl(identityOfInstantiatedMappedIntersection.ts, 0, 13)) +>label : Symbol(label, Decl(identityOfInstantiatedMappedIntersection.ts, 6, 52)) + diff --git a/tsc/testdata/baselines/reference/compiler/identityOfInstantiatedMappedIntersection.types b/tsc/testdata/baselines/reference/compiler/identityOfInstantiatedMappedIntersection.types new file mode 100644 index 0000000000000..51697776612a5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/identityOfInstantiatedMappedIntersection.types @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/identityOfInstantiatedMappedIntersection.ts] //// + +=== identityOfInstantiatedMappedIntersection.ts === +declare const brand: unique symbol; +>brand : unique symbol + +type Equal = (() => V extends T ? 1 : 2) extends (() => V extends U ? 1 : 2) ? true : false; +>Equal : Equal +>true : true +>false : false + +declare function assertEqual(value: Equal): void; +>assertEqual : (value: Equal) => void +>value : Equal + +type Flatten = { [K in keyof T]: T[K] }; +>Flatten : Flatten + +type Branded = Flatten<{ name: string }> & { [brand]: { label: true } }; +>Branded : Branded +>name : string +>[brand] : { label: true; } +>brand : unique symbol +>label : true +>true : true + +assertEqual(true); +>assertEqual(true) : void +>assertEqual : (value: Equal) => void +>name : string +>[brand] : { label: true; } +>brand : unique symbol +>label : true +>true : true +>true : true + diff --git a/tsc/testdata/baselines/reference/compiler/indexedAnyPredicateInForLoop.js b/tsc/testdata/baselines/reference/compiler/indexedAnyPredicateInForLoop.js new file mode 100644 index 0000000000000..d9256a80c2f01 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/indexedAnyPredicateInForLoop.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/indexedAnyPredicateInForLoop.ts] //// + +//// [indexedAnyPredicateInForLoop.ts] +declare function isPrimitive(value: any): value is string | number; +declare function createText(text: string | undefined): object; +function normalize(children: any) { + for (let index = 0; index < children.length; ++index) { + if (isPrimitive(children[index])) { + children[index] = createText(children[index]); + } + } +} + + +//// [indexedAnyPredicateInForLoop.js] +"use strict"; +function normalize(children) { + for (let index = 0; index < children.length; ++index) { + if (isPrimitive(children[index])) { + children[index] = createText(children[index]); + } + } +} diff --git a/tsc/testdata/baselines/reference/compiler/indexedAnyPredicateInForLoop.symbols b/tsc/testdata/baselines/reference/compiler/indexedAnyPredicateInForLoop.symbols new file mode 100644 index 0000000000000..90f6f89c39e75 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/indexedAnyPredicateInForLoop.symbols @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/indexedAnyPredicateInForLoop.ts] //// + +=== indexedAnyPredicateInForLoop.ts === +declare function isPrimitive(value: any): value is string | number; +>isPrimitive : Symbol(isPrimitive, Decl(indexedAnyPredicateInForLoop.ts, 0, 0)) +>value : Symbol(value, Decl(indexedAnyPredicateInForLoop.ts, 0, 29)) +>value : Symbol(value, Decl(indexedAnyPredicateInForLoop.ts, 0, 29)) + +declare function createText(text: string | undefined): object; +>createText : Symbol(createText, Decl(indexedAnyPredicateInForLoop.ts, 0, 67)) +>text : Symbol(text, Decl(indexedAnyPredicateInForLoop.ts, 1, 28)) + +function normalize(children: any) { +>normalize : Symbol(normalize, Decl(indexedAnyPredicateInForLoop.ts, 1, 62)) +>children : Symbol(children, Decl(indexedAnyPredicateInForLoop.ts, 2, 19)) + + for (let index = 0; index < children.length; ++index) { +>index : Symbol(index, Decl(indexedAnyPredicateInForLoop.ts, 3, 12)) +>index : Symbol(index, Decl(indexedAnyPredicateInForLoop.ts, 3, 12)) +>children : Symbol(children, Decl(indexedAnyPredicateInForLoop.ts, 2, 19)) +>index : Symbol(index, Decl(indexedAnyPredicateInForLoop.ts, 3, 12)) + + if (isPrimitive(children[index])) { +>isPrimitive : Symbol(isPrimitive, Decl(indexedAnyPredicateInForLoop.ts, 0, 0)) +>children : Symbol(children, Decl(indexedAnyPredicateInForLoop.ts, 2, 19)) +>index : Symbol(index, Decl(indexedAnyPredicateInForLoop.ts, 3, 12)) + + children[index] = createText(children[index]); +>children : Symbol(children, Decl(indexedAnyPredicateInForLoop.ts, 2, 19)) +>index : Symbol(index, Decl(indexedAnyPredicateInForLoop.ts, 3, 12)) +>createText : Symbol(createText, Decl(indexedAnyPredicateInForLoop.ts, 0, 67)) +>children : Symbol(children, Decl(indexedAnyPredicateInForLoop.ts, 2, 19)) +>index : Symbol(index, Decl(indexedAnyPredicateInForLoop.ts, 3, 12)) + } + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/indexedAnyPredicateInForLoop.types b/tsc/testdata/baselines/reference/compiler/indexedAnyPredicateInForLoop.types new file mode 100644 index 0000000000000..1409ee75961c8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/indexedAnyPredicateInForLoop.types @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/indexedAnyPredicateInForLoop.ts] //// + +=== indexedAnyPredicateInForLoop.ts === +declare function isPrimitive(value: any): value is string | number; +>isPrimitive : (value: any) => value is string | number +>value : any + +declare function createText(text: string | undefined): object; +>createText : (text: string | undefined) => object +>text : string | undefined + +function normalize(children: any) { +>normalize : (children: any) => void +>children : any + + for (let index = 0; index < children.length; ++index) { +>index : number +>0 : 0 +>index < children.length : boolean +>index : number +>children.length : any +>children : any +>length : any +>++index : number +>index : number + + if (isPrimitive(children[index])) { +>isPrimitive(children[index]) : boolean +>isPrimitive : (value: any) => value is string | number +>children[index] : any +>children : any +>index : number + + children[index] = createText(children[index]); +>children[index] = createText(children[index]) : object +>children[index] : any +>children : any +>index : number +>createText(children[index]) : object +>createText : (text: string | undefined) => object +>children[index] : any +>children : any +>index : number + } + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/inheritedOutputDirectoryRoot.errors.txt b/tsc/testdata/baselines/reference/compiler/inheritedOutputDirectoryRoot.errors.txt new file mode 100644 index 0000000000000..a31c8a87d1f13 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/inheritedOutputDirectoryRoot.errors.txt @@ -0,0 +1,16 @@ +/project/tsconfig.json(1,29): error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. + Visit https://aka.ms/ts6 for migration information. + + +==== /project/tsconfig.json (1 errors) ==== + { "extends": "./base.json", "compilerOptions": {}, "files": ["src/index.ts"] } + ~~~~~~~~~~~~~~~~~ +!!! error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. +!!! error TS5011: Visit https://aka.ms/ts6 for migration information. + +==== /project/src/index.ts (0 errors) ==== + export const value = 0; + +==== /project/base.json (0 errors) ==== + { "compilerOptions": { "outDir": "dist" } } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/inheritedOutputDirectoryRoot.js b/tsc/testdata/baselines/reference/compiler/inheritedOutputDirectoryRoot.js new file mode 100644 index 0000000000000..ccf7f864f655a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/inheritedOutputDirectoryRoot.js @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/inheritedOutputDirectoryRoot.ts] //// + +//// [base.json] +{ "compilerOptions": { "outDir": "dist" } } + +//// [index.ts] +export const value = 0; + + +//// [/project/dist/src/index.js] +export const value = 0; diff --git a/tsc/testdata/baselines/reference/compiler/inheritedOutputDirectoryRoot.symbols b/tsc/testdata/baselines/reference/compiler/inheritedOutputDirectoryRoot.symbols new file mode 100644 index 0000000000000..af2340ff00ec8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/inheritedOutputDirectoryRoot.symbols @@ -0,0 +1,6 @@ +//// [tests/cases/compiler/inheritedOutputDirectoryRoot.ts] //// + +=== /project/src/index.ts === +export const value = 0; +>value : Symbol(value, Decl(index.ts, 0, 12)) + diff --git a/tsc/testdata/baselines/reference/compiler/inheritedOutputDirectoryRoot.types b/tsc/testdata/baselines/reference/compiler/inheritedOutputDirectoryRoot.types new file mode 100644 index 0000000000000..5eb8aa142f544 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/inheritedOutputDirectoryRoot.types @@ -0,0 +1,7 @@ +//// [tests/cases/compiler/inheritedOutputDirectoryRoot.ts] //// + +=== /project/src/index.ts === +export const value = 0; +>value : 0 +>0 : 0 + diff --git a/tsc/testdata/baselines/reference/compiler/iteratorResultNullishValueAssignment.js b/tsc/testdata/baselines/reference/compiler/iteratorResultNullishValueAssignment.js new file mode 100644 index 0000000000000..e0b72e5b3b7af --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/iteratorResultNullishValueAssignment.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/iteratorResultNullishValueAssignment.ts] //// + +//// [iteratorResultNullishValueAssignment.ts] +function initialize(result: IteratorResult) { + if (result.value == null) { + result.value = {}; + } +} + + +//// [iteratorResultNullishValueAssignment.js] +"use strict"; +function initialize(result) { + if (result.value == null) { + result.value = {}; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/iteratorResultNullishValueAssignment.symbols b/tsc/testdata/baselines/reference/compiler/iteratorResultNullishValueAssignment.symbols new file mode 100644 index 0000000000000..18f2b09081255 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/iteratorResultNullishValueAssignment.symbols @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/iteratorResultNullishValueAssignment.ts] //// + +=== iteratorResultNullishValueAssignment.ts === +function initialize(result: IteratorResult) { +>initialize : Symbol(initialize, Decl(iteratorResultNullishValueAssignment.ts, 0, 0)) +>result : Symbol(result, Decl(iteratorResultNullishValueAssignment.ts, 0, 20)) +>IteratorResult : Symbol(IteratorResult, Decl(lib.es2015.iterable.d.ts, --, --)) + + if (result.value == null) { +>result.value : Symbol(value, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>result : Symbol(result, Decl(iteratorResultNullishValueAssignment.ts, 0, 20)) +>value : Symbol(value, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + result.value = {}; +>result.value : Symbol(value, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>result : Symbol(result, Decl(iteratorResultNullishValueAssignment.ts, 0, 20)) +>value : Symbol(value, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/iteratorResultNullishValueAssignment.types b/tsc/testdata/baselines/reference/compiler/iteratorResultNullishValueAssignment.types new file mode 100644 index 0000000000000..bb9edfdf6c343 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/iteratorResultNullishValueAssignment.types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/iteratorResultNullishValueAssignment.ts] //// + +=== iteratorResultNullishValueAssignment.ts === +function initialize(result: IteratorResult) { +>initialize : (result: IteratorResult) => void +>result : IteratorResult + + if (result.value == null) { +>result.value == null : boolean +>result.value : void | object +>result : IteratorResult +>value : void | object + + result.value = {}; +>result.value = {} : {} +>result.value : void | object +>result : IteratorResult +>value : void | object +>{} : {} + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/jsxChildrenExcessPropertySuppression.errors.txt b/tsc/testdata/baselines/reference/compiler/jsxChildrenExcessPropertySuppression.errors.txt new file mode 100644 index 0000000000000..a7e11543046c2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxChildrenExcessPropertySuppression.errors.txt @@ -0,0 +1,19 @@ +jsxChildrenExcessPropertySuppression.tsx(9,5): error TS2322: Type '{ depth: number; href: string; children: string; }' is not assignable to type '{ depth: number; }'. + Property 'href' does not exist on type '{ depth: number; }'. + + +==== jsxChildrenExcessPropertySuppression.tsx (1 errors) ==== + declare namespace JSX { + interface Element {} + interface ElementChildrenAttribute { children: {}; } + } + declare function Item(props: { depth: number }): JSX.Element; + // @ts-ignore + text; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/jsxChildrenExcessPropertySuppression.js b/tsc/testdata/baselines/reference/compiler/jsxChildrenExcessPropertySuppression.js new file mode 100644 index 0000000000000..b87a79fc6c338 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxChildrenExcessPropertySuppression.js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/jsxChildrenExcessPropertySuppression.tsx] //// + +//// [jsxChildrenExcessPropertySuppression.tsx] +declare namespace JSX { + interface Element {} + interface ElementChildrenAttribute { children: {}; } +} +declare function Item(props: { depth: number }): JSX.Element; +// @ts-ignore +text; + + +//// [jsxChildrenExcessPropertySuppression.jsx] +"use strict"; +// @ts-ignore +text; diff --git a/tsc/testdata/baselines/reference/compiler/jsxChildrenExcessPropertySuppression.symbols b/tsc/testdata/baselines/reference/compiler/jsxChildrenExcessPropertySuppression.symbols new file mode 100644 index 0000000000000..5240e8d208218 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxChildrenExcessPropertySuppression.symbols @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/jsxChildrenExcessPropertySuppression.tsx] //// + +=== jsxChildrenExcessPropertySuppression.tsx === +declare namespace JSX { +>JSX : Symbol(JSX, Decl(jsxChildrenExcessPropertySuppression.tsx, 0, 0)) + + interface Element {} +>Element : Symbol(Element, Decl(jsxChildrenExcessPropertySuppression.tsx, 0, 23)) + + interface ElementChildrenAttribute { children: {}; } +>ElementChildrenAttribute : Symbol(ElementChildrenAttribute, Decl(jsxChildrenExcessPropertySuppression.tsx, 1, 24)) +>children : Symbol(ElementChildrenAttribute.children, Decl(jsxChildrenExcessPropertySuppression.tsx, 2, 40)) +} +declare function Item(props: { depth: number }): JSX.Element; +>Item : Symbol(Item, Decl(jsxChildrenExcessPropertySuppression.tsx, 3, 1)) +>props : Symbol(props, Decl(jsxChildrenExcessPropertySuppression.tsx, 4, 22)) +>depth : Symbol(depth, Decl(jsxChildrenExcessPropertySuppression.tsx, 4, 30)) +>JSX : Symbol(JSX, Decl(jsxChildrenExcessPropertySuppression.tsx, 0, 0)) +>Element : Symbol(JSX.Element, Decl(jsxChildrenExcessPropertySuppression.tsx, 0, 23)) + +// @ts-ignore +Item : Symbol(Item, Decl(jsxChildrenExcessPropertySuppression.tsx, 3, 1)) + + depth={0} +>depth : Symbol(depth, Decl(jsxChildrenExcessPropertySuppression.tsx, 6, 5)) + + href="" +>href : Symbol(href, Decl(jsxChildrenExcessPropertySuppression.tsx, 7, 13)) + +>text; +>Item : Symbol(Item, Decl(jsxChildrenExcessPropertySuppression.tsx, 3, 1)) + diff --git a/tsc/testdata/baselines/reference/compiler/jsxChildrenExcessPropertySuppression.types b/tsc/testdata/baselines/reference/compiler/jsxChildrenExcessPropertySuppression.types new file mode 100644 index 0000000000000..700352626a15e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/jsxChildrenExcessPropertySuppression.types @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/jsxChildrenExcessPropertySuppression.tsx] //// + +=== jsxChildrenExcessPropertySuppression.tsx === +declare namespace JSX { + interface Element {} + interface ElementChildrenAttribute { children: {}; } +>children : {} +} +declare function Item(props: { depth: number }): JSX.Element; +>Item : (props: { depth: number; }) => JSX.Element +>props : { depth: number; } +>depth : number +>JSX : any + +// @ts-ignore +text : JSX.Element +>Item : (props: { depth: number; }) => JSX.Element + + depth={0} +>depth : number +>0 : 0 + + href="" +>href : string + +>text; +>Item : (props: { depth: number; }) => JSX.Element + diff --git a/tsc/testdata/baselines/reference/compiler/largeDiscriminantUnionArrayPredicate.js b/tsc/testdata/baselines/reference/compiler/largeDiscriminantUnionArrayPredicate.js new file mode 100644 index 0000000000000..3f1be9bd9aeef --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/largeDiscriminantUnionArrayPredicate.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/largeDiscriminantUnionArrayPredicate.ts] //// + +//// [largeDiscriminantUnionArrayPredicate.ts] +type TreeNode = + | { kind: 0 } + | { kind: 1 } + | { kind: 2 } + | { kind: 3 } + | { kind: 4 } + | { kind: 5 } + | { kind: 6 } + | { kind: 7 } + | { kind: 8 } + | { kind: 9 }; + +declare const ancestor: TreeNode | TreeNode[]; + +if (!Array.isArray(ancestor)) { + ancestor.kind; +} + + +//// [largeDiscriminantUnionArrayPredicate.js] +"use strict"; +if (!Array.isArray(ancestor)) { + ancestor.kind; +} diff --git a/tsc/testdata/baselines/reference/compiler/largeDiscriminantUnionArrayPredicate.symbols b/tsc/testdata/baselines/reference/compiler/largeDiscriminantUnionArrayPredicate.symbols new file mode 100644 index 0000000000000..06fea956193f7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/largeDiscriminantUnionArrayPredicate.symbols @@ -0,0 +1,53 @@ +//// [tests/cases/compiler/largeDiscriminantUnionArrayPredicate.ts] //// + +=== largeDiscriminantUnionArrayPredicate.ts === +type TreeNode = +>TreeNode : Symbol(TreeNode, Decl(largeDiscriminantUnionArrayPredicate.ts, 0, 0)) + + | { kind: 0 } +>kind : Symbol(kind, Decl(largeDiscriminantUnionArrayPredicate.ts, 1, 7)) + + | { kind: 1 } +>kind : Symbol(kind, Decl(largeDiscriminantUnionArrayPredicate.ts, 2, 7)) + + | { kind: 2 } +>kind : Symbol(kind, Decl(largeDiscriminantUnionArrayPredicate.ts, 3, 7)) + + | { kind: 3 } +>kind : Symbol(kind, Decl(largeDiscriminantUnionArrayPredicate.ts, 4, 7)) + + | { kind: 4 } +>kind : Symbol(kind, Decl(largeDiscriminantUnionArrayPredicate.ts, 5, 7)) + + | { kind: 5 } +>kind : Symbol(kind, Decl(largeDiscriminantUnionArrayPredicate.ts, 6, 7)) + + | { kind: 6 } +>kind : Symbol(kind, Decl(largeDiscriminantUnionArrayPredicate.ts, 7, 7)) + + | { kind: 7 } +>kind : Symbol(kind, Decl(largeDiscriminantUnionArrayPredicate.ts, 8, 7)) + + | { kind: 8 } +>kind : Symbol(kind, Decl(largeDiscriminantUnionArrayPredicate.ts, 9, 7)) + + | { kind: 9 }; +>kind : Symbol(kind, Decl(largeDiscriminantUnionArrayPredicate.ts, 10, 7)) + +declare const ancestor: TreeNode | TreeNode[]; +>ancestor : Symbol(ancestor, Decl(largeDiscriminantUnionArrayPredicate.ts, 12, 13)) +>TreeNode : Symbol(TreeNode, Decl(largeDiscriminantUnionArrayPredicate.ts, 0, 0)) +>TreeNode : Symbol(TreeNode, Decl(largeDiscriminantUnionArrayPredicate.ts, 0, 0)) + +if (!Array.isArray(ancestor)) { +>Array.isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more) +>isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --)) +>ancestor : Symbol(ancestor, Decl(largeDiscriminantUnionArrayPredicate.ts, 12, 13)) + + ancestor.kind; +>ancestor.kind : Symbol(kind, Decl(largeDiscriminantUnionArrayPredicate.ts, 1, 7), Decl(largeDiscriminantUnionArrayPredicate.ts, 2, 7), Decl(largeDiscriminantUnionArrayPredicate.ts, 3, 7), Decl(largeDiscriminantUnionArrayPredicate.ts, 4, 7), Decl(largeDiscriminantUnionArrayPredicate.ts, 5, 7) ... and 5 more) +>ancestor : Symbol(ancestor, Decl(largeDiscriminantUnionArrayPredicate.ts, 12, 13)) +>kind : Symbol(kind, Decl(largeDiscriminantUnionArrayPredicate.ts, 1, 7), Decl(largeDiscriminantUnionArrayPredicate.ts, 2, 7), Decl(largeDiscriminantUnionArrayPredicate.ts, 3, 7), Decl(largeDiscriminantUnionArrayPredicate.ts, 4, 7), Decl(largeDiscriminantUnionArrayPredicate.ts, 5, 7) ... and 5 more) +} + diff --git a/tsc/testdata/baselines/reference/compiler/largeDiscriminantUnionArrayPredicate.types b/tsc/testdata/baselines/reference/compiler/largeDiscriminantUnionArrayPredicate.types new file mode 100644 index 0000000000000..1f5ff2c13a149 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/largeDiscriminantUnionArrayPredicate.types @@ -0,0 +1,53 @@ +//// [tests/cases/compiler/largeDiscriminantUnionArrayPredicate.ts] //// + +=== largeDiscriminantUnionArrayPredicate.ts === +type TreeNode = +>TreeNode : TreeNode + + | { kind: 0 } +>kind : 0 + + | { kind: 1 } +>kind : 1 + + | { kind: 2 } +>kind : 2 + + | { kind: 3 } +>kind : 3 + + | { kind: 4 } +>kind : 4 + + | { kind: 5 } +>kind : 5 + + | { kind: 6 } +>kind : 6 + + | { kind: 7 } +>kind : 7 + + | { kind: 8 } +>kind : 8 + + | { kind: 9 }; +>kind : 9 + +declare const ancestor: TreeNode | TreeNode[]; +>ancestor : TreeNode[] | TreeNode + +if (!Array.isArray(ancestor)) { +>!Array.isArray(ancestor) : boolean +>Array.isArray(ancestor) : boolean +>Array.isArray : (arg: any) => arg is any[] +>Array : ArrayConstructor +>isArray : (arg: any) => arg is any[] +>ancestor : TreeNode[] | TreeNode + + ancestor.kind; +>ancestor.kind : 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 +>ancestor : TreeNode +>kind : 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 +} + diff --git a/tsc/testdata/baselines/reference/compiler/literalUnionAfterExcludedComparisons.js b/tsc/testdata/baselines/reference/compiler/literalUnionAfterExcludedComparisons.js new file mode 100644 index 0000000000000..a1a7bcfecde1c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/literalUnionAfterExcludedComparisons.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/literalUnionAfterExcludedComparisons.ts] //// + +//// [literalUnionAfterExcludedComparisons.ts] +type Runtime = "node" | "deno" | "bun"; +function readRuntime(value: string): Runtime { + if (value !== "node" && value !== "deno" && value !== "bun") { + throw new Error(); + } + return value; +} + + +//// [literalUnionAfterExcludedComparisons.js] +"use strict"; +function readRuntime(value) { + if (value !== "node" && value !== "deno" && value !== "bun") { + throw new Error(); + } + return value; +} diff --git a/tsc/testdata/baselines/reference/compiler/literalUnionAfterExcludedComparisons.symbols b/tsc/testdata/baselines/reference/compiler/literalUnionAfterExcludedComparisons.symbols new file mode 100644 index 0000000000000..246ebe7f424ce --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/literalUnionAfterExcludedComparisons.symbols @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/literalUnionAfterExcludedComparisons.ts] //// + +=== literalUnionAfterExcludedComparisons.ts === +type Runtime = "node" | "deno" | "bun"; +>Runtime : Symbol(Runtime, Decl(literalUnionAfterExcludedComparisons.ts, 0, 0)) + +function readRuntime(value: string): Runtime { +>readRuntime : Symbol(readRuntime, Decl(literalUnionAfterExcludedComparisons.ts, 0, 39)) +>value : Symbol(value, Decl(literalUnionAfterExcludedComparisons.ts, 1, 21)) +>Runtime : Symbol(Runtime, Decl(literalUnionAfterExcludedComparisons.ts, 0, 0)) + + if (value !== "node" && value !== "deno" && value !== "bun") { +>value : Symbol(value, Decl(literalUnionAfterExcludedComparisons.ts, 1, 21)) +>value : Symbol(value, Decl(literalUnionAfterExcludedComparisons.ts, 1, 21)) +>value : Symbol(value, Decl(literalUnionAfterExcludedComparisons.ts, 1, 21)) + + throw new Error(); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } + return value; +>value : Symbol(value, Decl(literalUnionAfterExcludedComparisons.ts, 1, 21)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/literalUnionAfterExcludedComparisons.types b/tsc/testdata/baselines/reference/compiler/literalUnionAfterExcludedComparisons.types new file mode 100644 index 0000000000000..4212f993a140d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/literalUnionAfterExcludedComparisons.types @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/literalUnionAfterExcludedComparisons.ts] //// + +=== literalUnionAfterExcludedComparisons.ts === +type Runtime = "node" | "deno" | "bun"; +>Runtime : Runtime + +function readRuntime(value: string): Runtime { +>readRuntime : (value: string) => Runtime +>value : string + + if (value !== "node" && value !== "deno" && value !== "bun") { +>value !== "node" && value !== "deno" && value !== "bun" : boolean +>value !== "node" && value !== "deno" : boolean +>value !== "node" : boolean +>value : string +>"node" : "node" +>value !== "deno" : boolean +>value : string +>"deno" : "deno" +>value !== "bun" : boolean +>value : string +>"bun" : "bun" + + throw new Error(); +>new Error() : Error +>Error : ErrorConstructor + } + return value; +>value : "bun" | "deno" | "node" +} + diff --git a/tsc/testdata/baselines/reference/compiler/logicalNotUndefinedComparison.js b/tsc/testdata/baselines/reference/compiler/logicalNotUndefinedComparison.js new file mode 100644 index 0000000000000..2fbdf28f79310 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/logicalNotUndefinedComparison.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/logicalNotUndefinedComparison.ts] //// + +//// [logicalNotUndefinedComparison.ts] +function isNode(object: { type?: string }) { + return !object.type !== undefined; +} + + +//// [logicalNotUndefinedComparison.js] +"use strict"; +function isNode(object) { + return !object.type !== undefined; +} diff --git a/tsc/testdata/baselines/reference/compiler/logicalNotUndefinedComparison.symbols b/tsc/testdata/baselines/reference/compiler/logicalNotUndefinedComparison.symbols new file mode 100644 index 0000000000000..2864dd480aff8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/logicalNotUndefinedComparison.symbols @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/logicalNotUndefinedComparison.ts] //// + +=== logicalNotUndefinedComparison.ts === +function isNode(object: { type?: string }) { +>isNode : Symbol(isNode, Decl(logicalNotUndefinedComparison.ts, 0, 0)) +>object : Symbol(object, Decl(logicalNotUndefinedComparison.ts, 0, 16)) +>type : Symbol(type, Decl(logicalNotUndefinedComparison.ts, 0, 25)) + + return !object.type !== undefined; +>object.type : Symbol(type, Decl(logicalNotUndefinedComparison.ts, 0, 25)) +>object : Symbol(object, Decl(logicalNotUndefinedComparison.ts, 0, 16)) +>type : Symbol(type, Decl(logicalNotUndefinedComparison.ts, 0, 25)) +>undefined : Symbol(undefined) +} + diff --git a/tsc/testdata/baselines/reference/compiler/logicalNotUndefinedComparison.types b/tsc/testdata/baselines/reference/compiler/logicalNotUndefinedComparison.types new file mode 100644 index 0000000000000..935f17724cc2d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/logicalNotUndefinedComparison.types @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/logicalNotUndefinedComparison.ts] //// + +=== logicalNotUndefinedComparison.ts === +function isNode(object: { type?: string }) { +>isNode : (object: { type?: string; }) => boolean +>object : { type?: string; } +>type : string | undefined + + return !object.type !== undefined; +>!object.type !== undefined : boolean +>!object.type : boolean +>object.type : string | undefined +>object : { type?: string; } +>type : string | undefined +>undefined : undefined +} + diff --git a/tsc/testdata/baselines/reference/compiler/loopArrayLengthInferenceCycle.js b/tsc/testdata/baselines/reference/compiler/loopArrayLengthInferenceCycle.js new file mode 100644 index 0000000000000..e20746cf785b2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/loopArrayLengthInferenceCycle.js @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/loopArrayLengthInferenceCycle.ts] //// + +//// [loopArrayLengthInferenceCycle.ts] +function tokenize() { + let state: { matches: string[]; groups: string[][] } | null = null; + while (true) { + let matches: string[] | null = null; + let action: string[] | null = null; + if (state) { + const groupEntry = state.groups[0]; + action = groupEntry; + } + matches = []; + if (action) { + if (matches.length !== action.length) throw new Error(); + state = { matches, groups: [] }; + } + } +} + + +//// [loopArrayLengthInferenceCycle.js] +"use strict"; +function tokenize() { + let state = null; + while (true) { + let matches = null; + let action = null; + if (state) { + const groupEntry = state.groups[0]; + action = groupEntry; + } + matches = []; + if (action) { + if (matches.length !== action.length) + throw new Error(); + state = { matches, groups: [] }; + } + } +} diff --git a/tsc/testdata/baselines/reference/compiler/loopArrayLengthInferenceCycle.symbols b/tsc/testdata/baselines/reference/compiler/loopArrayLengthInferenceCycle.symbols new file mode 100644 index 0000000000000..fa63f3ace005e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/loopArrayLengthInferenceCycle.symbols @@ -0,0 +1,54 @@ +//// [tests/cases/compiler/loopArrayLengthInferenceCycle.ts] //// + +=== loopArrayLengthInferenceCycle.ts === +function tokenize() { +>tokenize : Symbol(tokenize, Decl(loopArrayLengthInferenceCycle.ts, 0, 0)) + + let state: { matches: string[]; groups: string[][] } | null = null; +>state : Symbol(state, Decl(loopArrayLengthInferenceCycle.ts, 1, 7)) +>matches : Symbol(matches, Decl(loopArrayLengthInferenceCycle.ts, 1, 16)) +>groups : Symbol(groups, Decl(loopArrayLengthInferenceCycle.ts, 1, 35)) + + while (true) { + let matches: string[] | null = null; +>matches : Symbol(matches, Decl(loopArrayLengthInferenceCycle.ts, 3, 11)) + + let action: string[] | null = null; +>action : Symbol(action, Decl(loopArrayLengthInferenceCycle.ts, 4, 11)) + + if (state) { +>state : Symbol(state, Decl(loopArrayLengthInferenceCycle.ts, 1, 7)) + + const groupEntry = state.groups[0]; +>groupEntry : Symbol(groupEntry, Decl(loopArrayLengthInferenceCycle.ts, 6, 17)) +>state.groups : Symbol(groups, Decl(loopArrayLengthInferenceCycle.ts, 1, 35)) +>state : Symbol(state, Decl(loopArrayLengthInferenceCycle.ts, 1, 7)) +>groups : Symbol(groups, Decl(loopArrayLengthInferenceCycle.ts, 1, 35)) + + action = groupEntry; +>action : Symbol(action, Decl(loopArrayLengthInferenceCycle.ts, 4, 11)) +>groupEntry : Symbol(groupEntry, Decl(loopArrayLengthInferenceCycle.ts, 6, 17)) + } + matches = []; +>matches : Symbol(matches, Decl(loopArrayLengthInferenceCycle.ts, 3, 11)) + + if (action) { +>action : Symbol(action, Decl(loopArrayLengthInferenceCycle.ts, 4, 11)) + + if (matches.length !== action.length) throw new Error(); +>matches.length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) +>matches : Symbol(matches, Decl(loopArrayLengthInferenceCycle.ts, 3, 11)) +>length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) +>action.length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) +>action : Symbol(action, Decl(loopArrayLengthInferenceCycle.ts, 4, 11)) +>length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2022.error.d.ts, --, --)) + + state = { matches, groups: [] }; +>state : Symbol(state, Decl(loopArrayLengthInferenceCycle.ts, 1, 7)) +>matches : Symbol(matches, Decl(loopArrayLengthInferenceCycle.ts, 12, 21)) +>groups : Symbol(groups, Decl(loopArrayLengthInferenceCycle.ts, 12, 30)) + } + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/loopArrayLengthInferenceCycle.types b/tsc/testdata/baselines/reference/compiler/loopArrayLengthInferenceCycle.types new file mode 100644 index 0000000000000..48dd02ad26532 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/loopArrayLengthInferenceCycle.types @@ -0,0 +1,66 @@ +//// [tests/cases/compiler/loopArrayLengthInferenceCycle.ts] //// + +=== loopArrayLengthInferenceCycle.ts === +function tokenize() { +>tokenize : () => void + + let state: { matches: string[]; groups: string[][] } | null = null; +>state : { matches: string[]; groups: string[][]; } | null +>matches : string[] +>groups : string[][] + + while (true) { +>true : true + + let matches: string[] | null = null; +>matches : string[] | null + + let action: string[] | null = null; +>action : string[] | null + + if (state) { +>state : { matches: string[]; groups: string[][]; } | null + + const groupEntry = state.groups[0]; +>groupEntry : string[] +>state.groups[0] : string[] +>state.groups : string[][] +>state : { matches: string[]; groups: string[][]; } +>groups : string[][] +>0 : 0 + + action = groupEntry; +>action = groupEntry : string[] +>action : string[] | null +>groupEntry : string[] + } + matches = []; +>matches = [] : never[] +>matches : string[] | null +>[] : never[] + + if (action) { +>action : string[] | null + + if (matches.length !== action.length) throw new Error(); +>matches.length !== action.length : boolean +>matches.length : number +>matches : string[] +>length : number +>action.length : number +>action : string[] +>length : number +>new Error() : Error +>Error : ErrorConstructor + + state = { matches, groups: [] }; +>state = { matches, groups: [] } : { matches: string[]; groups: never[]; } +>state : { matches: string[]; groups: string[][]; } | null +>{ matches, groups: [] } : { matches: string[]; groups: never[]; } +>matches : string[] +>groups : never[] +>[] : never[] + } + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/messagePortHandlerEventTypes.symbols b/tsc/testdata/baselines/reference/compiler/messagePortHandlerEventTypes.symbols new file mode 100644 index 0000000000000..c234f2b4eaa95 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/messagePortHandlerEventTypes.symbols @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/messagePortHandlerEventTypes.ts] //// + +=== messagePortHandlerEventTypes.ts === +declare const port: MessagePort; +>port : Symbol(port, Decl(messagePortHandlerEventTypes.ts, 0, 13)) +>MessagePort : Symbol(MessagePort, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +port.onmessage = event => { +>port.onmessage : Symbol(MessageEventTarget.onmessage, Decl(lib.dom.d.ts, --, --)) +>port : Symbol(port, Decl(messagePortHandlerEventTypes.ts, 0, 13)) +>onmessage : Symbol(MessageEventTarget.onmessage, Decl(lib.dom.d.ts, --, --)) +>event : Symbol(event, Decl(messagePortHandlerEventTypes.ts, 1, 16)) + + event.data; +>event.data : Symbol(MessageEvent.data, Decl(lib.dom.d.ts, --, --)) +>event : Symbol(event, Decl(messagePortHandlerEventTypes.ts, 1, 16)) +>data : Symbol(MessageEvent.data, Decl(lib.dom.d.ts, --, --)) + +}; +port.onmessageerror = event => { +>port.onmessageerror : Symbol(MessageEventTarget.onmessageerror, Decl(lib.dom.d.ts, --, --)) +>port : Symbol(port, Decl(messagePortHandlerEventTypes.ts, 0, 13)) +>onmessageerror : Symbol(MessageEventTarget.onmessageerror, Decl(lib.dom.d.ts, --, --)) +>event : Symbol(event, Decl(messagePortHandlerEventTypes.ts, 4, 21)) + + event.data; +>event.data : Symbol(MessageEvent.data, Decl(lib.dom.d.ts, --, --)) +>event : Symbol(event, Decl(messagePortHandlerEventTypes.ts, 4, 21)) +>data : Symbol(MessageEvent.data, Decl(lib.dom.d.ts, --, --)) + +}; + diff --git a/tsc/testdata/baselines/reference/compiler/messagePortHandlerEventTypes.types b/tsc/testdata/baselines/reference/compiler/messagePortHandlerEventTypes.types new file mode 100644 index 0000000000000..e9d12ca08cab1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/messagePortHandlerEventTypes.types @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/messagePortHandlerEventTypes.ts] //// + +=== messagePortHandlerEventTypes.ts === +declare const port: MessagePort; +>port : MessagePort + +port.onmessage = event => { +>port.onmessage = event => { event.data;} : (this: MessagePort, event: MessageEvent) => void +>port.onmessage : ((this: MessagePort, ev: MessageEvent) => any) | null +>port : MessagePort +>onmessage : ((this: MessagePort, ev: MessageEvent) => any) | null +>event => { event.data;} : (this: MessagePort, event: MessageEvent) => void +>event : MessageEvent + + event.data; +>event.data : any +>event : MessageEvent +>data : any + +}; +port.onmessageerror = event => { +>port.onmessageerror = event => { event.data;} : (this: MessagePort, event: MessageEvent) => void +>port.onmessageerror : ((this: MessagePort, ev: MessageEvent) => any) | null +>port : MessagePort +>onmessageerror : ((this: MessagePort, ev: MessageEvent) => any) | null +>event => { event.data;} : (this: MessagePort, event: MessageEvent) => void +>event : MessageEvent + + event.data; +>event.data : any +>event : MessageEvent +>data : any + +}; + diff --git a/tsc/testdata/baselines/reference/compiler/missingTypesConditionDefaultSidecar.symbols b/tsc/testdata/baselines/reference/compiler/missingTypesConditionDefaultSidecar.symbols new file mode 100644 index 0000000000000..d045288fa9d70 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/missingTypesConditionDefaultSidecar.symbols @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/missingTypesConditionDefaultSidecar.ts] //// + +=== node_modules/font/sans.d.ts === +export const font: { className: string }; +>font : Symbol(font, Decl(sans.d.ts, 0, 12)) +>className : Symbol(className, Decl(sans.d.ts, 0, 20)) + +=== main.ts === +import { font } from "font/sans"; +>font : Symbol(font, Decl(main.ts, 0, 8)) + +font.className; +>font.className : Symbol(className, Decl(sans.d.ts, 0, 20)) +>font : Symbol(font, Decl(main.ts, 0, 8)) +>className : Symbol(className, Decl(sans.d.ts, 0, 20)) + diff --git a/tsc/testdata/baselines/reference/compiler/missingTypesConditionDefaultSidecar.trace.json b/tsc/testdata/baselines/reference/compiler/missingTypesConditionDefaultSidecar.trace.json new file mode 100644 index 0000000000000..8b45d5582dd2d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/missingTypesConditionDefaultSidecar.trace.json @@ -0,0 +1,23 @@ +======== Resolving module 'font/sans' from '/.src/main.ts'. ======== +Explicitly specified module resolution kind: 'Bundler'. +Resolving in CJS mode with conditions 'import', 'types'. +File '/.src/package.json' does not exist. +File '/package.json' does not exist. +Loading module 'font/sans' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. +Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Found 'package.json' at '/.src/node_modules/font/package.json'. +Entering conditional exports. +Matched 'exports' condition 'types'. +Using 'exports' subpath './sans' with target './missing.d.ts'. +File '/.src/node_modules/font/missing.d.ts' does not exist. +Failed to resolve under condition 'types'. +Matched 'exports' condition 'default'. +Using 'exports' subpath './sans' with target './sans.js'. +File name '/.src/node_modules/font/sans.js' has a '.js' extension - stripping it. +File '/.src/node_modules/font/sans.ts' does not exist. +File '/.src/node_modules/font/sans.tsx' does not exist. +File '/.src/node_modules/font/sans.d.ts' exists - use it as a name resolution result. +Resolved under condition 'default'. +Exiting conditional exports. +Resolving real path for '/.src/node_modules/font/sans.d.ts', result '/.src/node_modules/font/sans.d.ts'. +======== Module name 'font/sans' was successfully resolved to '/.src/node_modules/font/sans.d.ts'. ======== diff --git a/tsc/testdata/baselines/reference/compiler/missingTypesConditionDefaultSidecar.types b/tsc/testdata/baselines/reference/compiler/missingTypesConditionDefaultSidecar.types new file mode 100644 index 0000000000000..1faada1e11191 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/missingTypesConditionDefaultSidecar.types @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/missingTypesConditionDefaultSidecar.ts] //// + +=== node_modules/font/sans.d.ts === +export const font: { className: string }; +>font : { className: string; } +>className : string + +=== main.ts === +import { font } from "font/sans"; +>font : { className: string; } + +font.className; +>font.className : string +>font : { className: string; } +>className : string + diff --git a/tsc/testdata/baselines/reference/compiler/moduleKeywordInstantiatedNamespace.errors.txt b/tsc/testdata/baselines/reference/compiler/moduleKeywordInstantiatedNamespace.errors.txt new file mode 100644 index 0000000000000..257e5f5fbbbf2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/moduleKeywordInstantiatedNamespace.errors.txt @@ -0,0 +1,11 @@ +moduleKeywordInstantiatedNamespace.ts(1,8): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + + +==== moduleKeywordInstantiatedNamespace.ts (1 errors) ==== + module Runtime { + ~~~~~~~ +!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + export const value = 0; + } + Runtime.value; + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/moduleKeywordInstantiatedNamespace.symbols b/tsc/testdata/baselines/reference/compiler/moduleKeywordInstantiatedNamespace.symbols new file mode 100644 index 0000000000000..b6a8427268b5f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/moduleKeywordInstantiatedNamespace.symbols @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/moduleKeywordInstantiatedNamespace.ts] //// + +=== moduleKeywordInstantiatedNamespace.ts === +module Runtime { +>Runtime : Symbol(Runtime, Decl(moduleKeywordInstantiatedNamespace.ts, 0, 0)) + + export const value = 0; +>value : Symbol(value, Decl(moduleKeywordInstantiatedNamespace.ts, 1, 16)) +} +Runtime.value; +>Runtime.value : Symbol(Runtime.value, Decl(moduleKeywordInstantiatedNamespace.ts, 1, 16)) +>Runtime : Symbol(Runtime, Decl(moduleKeywordInstantiatedNamespace.ts, 0, 0)) +>value : Symbol(Runtime.value, Decl(moduleKeywordInstantiatedNamespace.ts, 1, 16)) + diff --git a/tsc/testdata/baselines/reference/compiler/moduleKeywordInstantiatedNamespace.types b/tsc/testdata/baselines/reference/compiler/moduleKeywordInstantiatedNamespace.types new file mode 100644 index 0000000000000..216d4b86ccda6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/moduleKeywordInstantiatedNamespace.types @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/moduleKeywordInstantiatedNamespace.ts] //// + +=== moduleKeywordInstantiatedNamespace.ts === +module Runtime { +>Runtime : typeof Runtime + + export const value = 0; +>value : 0 +>0 : 0 +} +Runtime.value; +>Runtime.value : 0 +>Runtime : typeof Runtime +>value : 0 + diff --git a/tsc/testdata/baselines/reference/compiler/namespaceFunctionReservedDefaultParameter.errors.txt b/tsc/testdata/baselines/reference/compiler/namespaceFunctionReservedDefaultParameter.errors.txt new file mode 100644 index 0000000000000..a0e7df42afc6b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/namespaceFunctionReservedDefaultParameter.errors.txt @@ -0,0 +1,18 @@ +namespaceFunctionReservedDefaultParameter.ts(2,29): error TS1212: Identifier expected. 'static' is a reserved word in strict mode. +namespaceFunctionReservedDefaultParameter.ts(3,13): error TS1212: Identifier expected. 'static' is a reserved word in strict mode. + + +==== namespaceFunctionReservedDefaultParameter.ts (2 errors) ==== + namespace Dependencies { + export function scripts(static = false) { + ~~~~~~ +!!! error TS1212: Identifier expected. 'static' is a reserved word in strict mode. + if (static) { + ~~~~~~ +!!! error TS1212: Identifier expected. 'static' is a reserved word in strict mode. + return "static.js"; + } + return "interactive.js"; + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/namespaceFunctionReservedDefaultParameter.js b/tsc/testdata/baselines/reference/compiler/namespaceFunctionReservedDefaultParameter.js new file mode 100644 index 0000000000000..5bb89062243f6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/namespaceFunctionReservedDefaultParameter.js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/namespaceFunctionReservedDefaultParameter.ts] //// + +//// [namespaceFunctionReservedDefaultParameter.ts] +namespace Dependencies { + export function scripts(static = false) { + if (static) { + return "static.js"; + } + return "interactive.js"; + } +} + + +//// [namespaceFunctionReservedDefaultParameter.js] +"use strict"; +var Dependencies; +(function (Dependencies) { + function scripts(static = false) { + if (static) { + return "static.js"; + } + return "interactive.js"; + } + Dependencies.scripts = scripts; +})(Dependencies || (Dependencies = {})); diff --git a/tsc/testdata/baselines/reference/compiler/namespaceFunctionReservedDefaultParameter.symbols b/tsc/testdata/baselines/reference/compiler/namespaceFunctionReservedDefaultParameter.symbols new file mode 100644 index 0000000000000..62ef39acc0f2b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/namespaceFunctionReservedDefaultParameter.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/namespaceFunctionReservedDefaultParameter.ts] //// + +=== namespaceFunctionReservedDefaultParameter.ts === +namespace Dependencies { +>Dependencies : Symbol(Dependencies, Decl(namespaceFunctionReservedDefaultParameter.ts, 0, 0)) + + export function scripts(static = false) { +>scripts : Symbol(scripts, Decl(namespaceFunctionReservedDefaultParameter.ts, 0, 24)) +>static : Symbol(static, Decl(namespaceFunctionReservedDefaultParameter.ts, 1, 28)) + + if (static) { +>static : Symbol(static, Decl(namespaceFunctionReservedDefaultParameter.ts, 1, 28)) + + return "static.js"; + } + return "interactive.js"; + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/namespaceFunctionReservedDefaultParameter.types b/tsc/testdata/baselines/reference/compiler/namespaceFunctionReservedDefaultParameter.types new file mode 100644 index 0000000000000..b43c1d3dba508 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/namespaceFunctionReservedDefaultParameter.types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/namespaceFunctionReservedDefaultParameter.ts] //// + +=== namespaceFunctionReservedDefaultParameter.ts === +namespace Dependencies { +>Dependencies : typeof Dependencies + + export function scripts(static = false) { +>scripts : (static?: boolean) => "interactive.js" | "static.js" +>static : boolean +>false : false + + if (static) { +>static : boolean + + return "static.js"; +>"static.js" : "static.js" + } + return "interactive.js"; +>"interactive.js" : "interactive.js" + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/newTargetUndefinedEquality.js b/tsc/testdata/baselines/reference/compiler/newTargetUndefinedEquality.js new file mode 100644 index 0000000000000..f5c34dd882fb4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/newTargetUndefinedEquality.js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/newTargetUndefinedEquality.ts] //// + +//// [newTargetUndefinedEquality.ts] +class ConstructorGuard { + constructor() { + if (new.target === undefined) throw TypeError("Constructor requires new"); + } +} + + +//// [newTargetUndefinedEquality.js] +"use strict"; +class ConstructorGuard { + constructor() { + if (new.target === undefined) + throw TypeError("Constructor requires new"); + } +} diff --git a/tsc/testdata/baselines/reference/compiler/newTargetUndefinedEquality.symbols b/tsc/testdata/baselines/reference/compiler/newTargetUndefinedEquality.symbols new file mode 100644 index 0000000000000..4728644830fb5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/newTargetUndefinedEquality.symbols @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/newTargetUndefinedEquality.ts] //// + +=== newTargetUndefinedEquality.ts === +class ConstructorGuard { +>ConstructorGuard : Symbol(ConstructorGuard, Decl(newTargetUndefinedEquality.ts, 0, 0)) + + constructor() { + if (new.target === undefined) throw TypeError("Constructor requires new"); +>new.target : Symbol(ConstructorGuard, Decl(newTargetUndefinedEquality.ts, 0, 0)) +>target : Symbol(ConstructorGuard, Decl(newTargetUndefinedEquality.ts, 0, 0)) +>undefined : Symbol(undefined) +>TypeError : Symbol(TypeError, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/newTargetUndefinedEquality.types b/tsc/testdata/baselines/reference/compiler/newTargetUndefinedEquality.types new file mode 100644 index 0000000000000..55a7ec4a957e0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/newTargetUndefinedEquality.types @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/newTargetUndefinedEquality.ts] //// + +=== newTargetUndefinedEquality.ts === +class ConstructorGuard { +>ConstructorGuard : ConstructorGuard + + constructor() { + if (new.target === undefined) throw TypeError("Constructor requires new"); +>new.target === undefined : boolean +>new.target : typeof ConstructorGuard +>target : typeof ConstructorGuard +>undefined : undefined +>TypeError("Constructor requires new") : TypeError +>TypeError : TypeErrorConstructor +>"Constructor requires new" : "Constructor requires new" + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/nonStrictOptionalNeverResult.js b/tsc/testdata/baselines/reference/compiler/nonStrictOptionalNeverResult.js new file mode 100644 index 0000000000000..a12077aeb3f87 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/nonStrictOptionalNeverResult.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/nonStrictOptionalNeverResult.ts] //// + +//// [nonStrictOptionalNeverResult.ts] +type Result = { error: string; details?: never } | { details: { link: string }; error?: never }; +function read(result: Result) { + if (result.error || !result.details) return; + return result.details.link; +} + + +//// [nonStrictOptionalNeverResult.js] +"use strict"; +function read(result) { + if (result.error || !result.details) + return; + return result.details.link; +} diff --git a/tsc/testdata/baselines/reference/compiler/nonStrictOptionalNeverResult.symbols b/tsc/testdata/baselines/reference/compiler/nonStrictOptionalNeverResult.symbols new file mode 100644 index 0000000000000..3a159ce1ed91d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/nonStrictOptionalNeverResult.symbols @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/nonStrictOptionalNeverResult.ts] //// + +=== nonStrictOptionalNeverResult.ts === +type Result = { error: string; details?: never } | { details: { link: string }; error?: never }; +>Result : Symbol(Result, Decl(nonStrictOptionalNeverResult.ts, 0, 0)) +>error : Symbol(error, Decl(nonStrictOptionalNeverResult.ts, 0, 15)) +>details : Symbol(details, Decl(nonStrictOptionalNeverResult.ts, 0, 30)) +>details : Symbol(details, Decl(nonStrictOptionalNeverResult.ts, 0, 52)) +>link : Symbol(link, Decl(nonStrictOptionalNeverResult.ts, 0, 63)) +>error : Symbol(error, Decl(nonStrictOptionalNeverResult.ts, 0, 79)) + +function read(result: Result) { +>read : Symbol(read, Decl(nonStrictOptionalNeverResult.ts, 0, 96)) +>result : Symbol(result, Decl(nonStrictOptionalNeverResult.ts, 1, 14)) +>Result : Symbol(Result, Decl(nonStrictOptionalNeverResult.ts, 0, 0)) + + if (result.error || !result.details) return; +>result.error : Symbol(error, Decl(nonStrictOptionalNeverResult.ts, 0, 15), Decl(nonStrictOptionalNeverResult.ts, 0, 79)) +>result : Symbol(result, Decl(nonStrictOptionalNeverResult.ts, 1, 14)) +>error : Symbol(error, Decl(nonStrictOptionalNeverResult.ts, 0, 15), Decl(nonStrictOptionalNeverResult.ts, 0, 79)) +>result.details : Symbol(details, Decl(nonStrictOptionalNeverResult.ts, 0, 30), Decl(nonStrictOptionalNeverResult.ts, 0, 52)) +>result : Symbol(result, Decl(nonStrictOptionalNeverResult.ts, 1, 14)) +>details : Symbol(details, Decl(nonStrictOptionalNeverResult.ts, 0, 30), Decl(nonStrictOptionalNeverResult.ts, 0, 52)) + + return result.details.link; +>result.details.link : Symbol(link, Decl(nonStrictOptionalNeverResult.ts, 0, 63)) +>result.details : Symbol(details, Decl(nonStrictOptionalNeverResult.ts, 0, 30), Decl(nonStrictOptionalNeverResult.ts, 0, 52)) +>result : Symbol(result, Decl(nonStrictOptionalNeverResult.ts, 1, 14)) +>details : Symbol(details, Decl(nonStrictOptionalNeverResult.ts, 0, 30), Decl(nonStrictOptionalNeverResult.ts, 0, 52)) +>link : Symbol(link, Decl(nonStrictOptionalNeverResult.ts, 0, 63)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/nonStrictOptionalNeverResult.types b/tsc/testdata/baselines/reference/compiler/nonStrictOptionalNeverResult.types new file mode 100644 index 0000000000000..c1367a5a126dc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/nonStrictOptionalNeverResult.types @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/nonStrictOptionalNeverResult.ts] //// + +=== nonStrictOptionalNeverResult.ts === +type Result = { error: string; details?: never } | { details: { link: string }; error?: never }; +>Result : Result +>error : string +>details : never +>details : { link: string; } +>link : string +>error : never + +function read(result: Result) { +>read : (result: Result) => string +>result : Result + + if (result.error || !result.details) return; +>result.error || !result.details : string | boolean +>result.error : string +>result : Result +>error : string +>!result.details : boolean +>result.details : { link: string; } +>result : Result +>details : { link: string; } + + return result.details.link; +>result.details.link : string +>result.details : { link: string; } +>result : Result +>details : { link: string; } +>link : string +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterBreak.js b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterBreak.js new file mode 100644 index 0000000000000..502b5fdc3f07a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterBreak.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/numericCompoundAssignmentAfterBreak.ts] //// + +//// [numericCompoundAssignmentAfterBreak.ts] +function drain(count: number) { + for (;;) { + if (count === 0) break; + count -= 1; + } +} + + +//// [numericCompoundAssignmentAfterBreak.js] +"use strict"; +function drain(count) { + for (;;) { + if (count === 0) + break; + count -= 1; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterBreak.symbols b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterBreak.symbols new file mode 100644 index 0000000000000..04bea4239ddd5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterBreak.symbols @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/numericCompoundAssignmentAfterBreak.ts] //// + +=== numericCompoundAssignmentAfterBreak.ts === +function drain(count: number) { +>drain : Symbol(drain, Decl(numericCompoundAssignmentAfterBreak.ts, 0, 0)) +>count : Symbol(count, Decl(numericCompoundAssignmentAfterBreak.ts, 0, 15)) + + for (;;) { + if (count === 0) break; +>count : Symbol(count, Decl(numericCompoundAssignmentAfterBreak.ts, 0, 15)) + + count -= 1; +>count : Symbol(count, Decl(numericCompoundAssignmentAfterBreak.ts, 0, 15)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterBreak.types b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterBreak.types new file mode 100644 index 0000000000000..c0b8aa98bba1f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterBreak.types @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/numericCompoundAssignmentAfterBreak.ts] //// + +=== numericCompoundAssignmentAfterBreak.ts === +function drain(count: number) { +>drain : (count: number) => void +>count : number + + for (;;) { + if (count === 0) break; +>count === 0 : boolean +>count : number +>0 : 0 + + count -= 1; +>count -= 1 : number +>count : number +>1 : 1 + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterContinue.js b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterContinue.js new file mode 100644 index 0000000000000..e6efa37e29b75 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterContinue.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/numericCompoundAssignmentAfterContinue.ts] //// + +//// [numericCompoundAssignmentAfterContinue.ts] +function consume(count: number) { + for (;;) { + if (count === 0) continue; + count -= 1; + } +} + + +//// [numericCompoundAssignmentAfterContinue.js] +"use strict"; +function consume(count) { + for (;;) { + if (count === 0) + continue; + count -= 1; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterContinue.symbols b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterContinue.symbols new file mode 100644 index 0000000000000..a5c831415ca2e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterContinue.symbols @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/numericCompoundAssignmentAfterContinue.ts] //// + +=== numericCompoundAssignmentAfterContinue.ts === +function consume(count: number) { +>consume : Symbol(consume, Decl(numericCompoundAssignmentAfterContinue.ts, 0, 0)) +>count : Symbol(count, Decl(numericCompoundAssignmentAfterContinue.ts, 0, 17)) + + for (;;) { + if (count === 0) continue; +>count : Symbol(count, Decl(numericCompoundAssignmentAfterContinue.ts, 0, 17)) + + count -= 1; +>count : Symbol(count, Decl(numericCompoundAssignmentAfterContinue.ts, 0, 17)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterContinue.types b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterContinue.types new file mode 100644 index 0000000000000..09a513c161e98 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterContinue.types @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/numericCompoundAssignmentAfterContinue.ts] //// + +=== numericCompoundAssignmentAfterContinue.ts === +function consume(count: number) { +>consume : (count: number) => void +>count : number + + for (;;) { + if (count === 0) continue; +>count === 0 : boolean +>count : number +>0 : 0 + + count -= 1; +>count -= 1 : number +>count : number +>1 : 1 + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterExcludedZero.js b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterExcludedZero.js new file mode 100644 index 0000000000000..571d9f44cdf95 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterExcludedZero.js @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/numericCompoundAssignmentAfterExcludedZero.ts] //// + +//// [numericCompoundAssignmentAfterExcludedZero.ts] +function divide(value: number, divisor: number) { + if (value === 0) return; + value /= divisor; +} + + +//// [numericCompoundAssignmentAfterExcludedZero.js] +"use strict"; +function divide(value, divisor) { + if (value === 0) + return; + value /= divisor; +} diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterExcludedZero.symbols b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterExcludedZero.symbols new file mode 100644 index 0000000000000..9c5935a807fdb --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterExcludedZero.symbols @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/numericCompoundAssignmentAfterExcludedZero.ts] //// + +=== numericCompoundAssignmentAfterExcludedZero.ts === +function divide(value: number, divisor: number) { +>divide : Symbol(divide, Decl(numericCompoundAssignmentAfterExcludedZero.ts, 0, 0)) +>value : Symbol(value, Decl(numericCompoundAssignmentAfterExcludedZero.ts, 0, 16)) +>divisor : Symbol(divisor, Decl(numericCompoundAssignmentAfterExcludedZero.ts, 0, 30)) + + if (value === 0) return; +>value : Symbol(value, Decl(numericCompoundAssignmentAfterExcludedZero.ts, 0, 16)) + + value /= divisor; +>value : Symbol(value, Decl(numericCompoundAssignmentAfterExcludedZero.ts, 0, 16)) +>divisor : Symbol(divisor, Decl(numericCompoundAssignmentAfterExcludedZero.ts, 0, 30)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterExcludedZero.types b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterExcludedZero.types new file mode 100644 index 0000000000000..5839afcb5200a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentAfterExcludedZero.types @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/numericCompoundAssignmentAfterExcludedZero.ts] //// + +=== numericCompoundAssignmentAfterExcludedZero.ts === +function divide(value: number, divisor: number) { +>divide : (value: number, divisor: number) => void +>value : number +>divisor : number + + if (value === 0) return; +>value === 0 : boolean +>value : number +>0 : 0 + + value /= divisor; +>value /= divisor : number +>value : number +>divisor : number +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInCallback.js b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInCallback.js new file mode 100644 index 0000000000000..cee3bc6e5eccb --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInCallback.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/numericCompoundAssignmentInCallback.ts] //// + +//// [numericCompoundAssignmentInCallback.ts] +function createConsumer(count: number) { + return () => { + if (count === 0) return; + count -= 1; + }; +} + + +//// [numericCompoundAssignmentInCallback.js] +"use strict"; +function createConsumer(count) { + return () => { + if (count === 0) + return; + count -= 1; + }; +} diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInCallback.symbols b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInCallback.symbols new file mode 100644 index 0000000000000..0dd38c58724c8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInCallback.symbols @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/numericCompoundAssignmentInCallback.ts] //// + +=== numericCompoundAssignmentInCallback.ts === +function createConsumer(count: number) { +>createConsumer : Symbol(createConsumer, Decl(numericCompoundAssignmentInCallback.ts, 0, 0)) +>count : Symbol(count, Decl(numericCompoundAssignmentInCallback.ts, 0, 24)) + + return () => { + if (count === 0) return; +>count : Symbol(count, Decl(numericCompoundAssignmentInCallback.ts, 0, 24)) + + count -= 1; +>count : Symbol(count, Decl(numericCompoundAssignmentInCallback.ts, 0, 24)) + + }; +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInCallback.types b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInCallback.types new file mode 100644 index 0000000000000..ffc6d0d5e3b3f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInCallback.types @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/numericCompoundAssignmentInCallback.ts] //// + +=== numericCompoundAssignmentInCallback.ts === +function createConsumer(count: number) { +>createConsumer : (count: number) => () => void +>count : number + + return () => { +>() => { if (count === 0) return; count -= 1; } : () => void + + if (count === 0) return; +>count === 0 : boolean +>count : number +>0 : 0 + + count -= 1; +>count -= 1 : number +>count : number +>1 : 1 + + }; +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInElseBranch.js b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInElseBranch.js new file mode 100644 index 0000000000000..714ae8098d3f3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInElseBranch.js @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/numericCompoundAssignmentInElseBranch.ts] //// + +//// [numericCompoundAssignmentInElseBranch.ts] +function accumulate(total: number, width: number, kernedWidth: number) { + if (total === 0) { + total += width; + } else { + total += kernedWidth; + } +} + + +//// [numericCompoundAssignmentInElseBranch.js] +"use strict"; +function accumulate(total, width, kernedWidth) { + if (total === 0) { + total += width; + } + else { + total += kernedWidth; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInElseBranch.symbols b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInElseBranch.symbols new file mode 100644 index 0000000000000..070cfb4d57fb1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInElseBranch.symbols @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/numericCompoundAssignmentInElseBranch.ts] //// + +=== numericCompoundAssignmentInElseBranch.ts === +function accumulate(total: number, width: number, kernedWidth: number) { +>accumulate : Symbol(accumulate, Decl(numericCompoundAssignmentInElseBranch.ts, 0, 0)) +>total : Symbol(total, Decl(numericCompoundAssignmentInElseBranch.ts, 0, 20)) +>width : Symbol(width, Decl(numericCompoundAssignmentInElseBranch.ts, 0, 34)) +>kernedWidth : Symbol(kernedWidth, Decl(numericCompoundAssignmentInElseBranch.ts, 0, 49)) + + if (total === 0) { +>total : Symbol(total, Decl(numericCompoundAssignmentInElseBranch.ts, 0, 20)) + + total += width; +>total : Symbol(total, Decl(numericCompoundAssignmentInElseBranch.ts, 0, 20)) +>width : Symbol(width, Decl(numericCompoundAssignmentInElseBranch.ts, 0, 34)) + + } else { + total += kernedWidth; +>total : Symbol(total, Decl(numericCompoundAssignmentInElseBranch.ts, 0, 20)) +>kernedWidth : Symbol(kernedWidth, Decl(numericCompoundAssignmentInElseBranch.ts, 0, 49)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInElseBranch.types b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInElseBranch.types new file mode 100644 index 0000000000000..e0bf5042fdc9e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInElseBranch.types @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/numericCompoundAssignmentInElseBranch.ts] //// + +=== numericCompoundAssignmentInElseBranch.ts === +function accumulate(total: number, width: number, kernedWidth: number) { +>accumulate : (total: number, width: number, kernedWidth: number) => void +>total : number +>width : number +>kernedWidth : number + + if (total === 0) { +>total === 0 : boolean +>total : number +>0 : 0 + + total += width; +>total += width : number +>total : number +>width : number + + } else { + total += kernedWidth; +>total += kernedWidth : number +>total : number +>kernedWidth : number + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInForUpdateAfterExcludedZero.js b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInForUpdateAfterExcludedZero.js new file mode 100644 index 0000000000000..c489c6bb3b445 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInForUpdateAfterExcludedZero.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/numericCompoundAssignmentInForUpdateAfterExcludedZero.ts] //// + +//// [numericCompoundAssignmentInForUpdateAfterExcludedZero.ts] +function shift(bitmap: number) { + for (let index = 0; bitmap !== 0; index++, bitmap >>>= 1) {} +} + + +//// [numericCompoundAssignmentInForUpdateAfterExcludedZero.js] +"use strict"; +function shift(bitmap) { + for (let index = 0; bitmap !== 0; index++, bitmap >>>= 1) { } +} diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInForUpdateAfterExcludedZero.symbols b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInForUpdateAfterExcludedZero.symbols new file mode 100644 index 0000000000000..1998f2601e44c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInForUpdateAfterExcludedZero.symbols @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/numericCompoundAssignmentInForUpdateAfterExcludedZero.ts] //// + +=== numericCompoundAssignmentInForUpdateAfterExcludedZero.ts === +function shift(bitmap: number) { +>shift : Symbol(shift, Decl(numericCompoundAssignmentInForUpdateAfterExcludedZero.ts, 0, 0)) +>bitmap : Symbol(bitmap, Decl(numericCompoundAssignmentInForUpdateAfterExcludedZero.ts, 0, 15)) + + for (let index = 0; bitmap !== 0; index++, bitmap >>>= 1) {} +>index : Symbol(index, Decl(numericCompoundAssignmentInForUpdateAfterExcludedZero.ts, 1, 12)) +>bitmap : Symbol(bitmap, Decl(numericCompoundAssignmentInForUpdateAfterExcludedZero.ts, 0, 15)) +>index : Symbol(index, Decl(numericCompoundAssignmentInForUpdateAfterExcludedZero.ts, 1, 12)) +>bitmap : Symbol(bitmap, Decl(numericCompoundAssignmentInForUpdateAfterExcludedZero.ts, 0, 15)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInForUpdateAfterExcludedZero.types b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInForUpdateAfterExcludedZero.types new file mode 100644 index 0000000000000..4af6920adb6bb --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInForUpdateAfterExcludedZero.types @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/numericCompoundAssignmentInForUpdateAfterExcludedZero.ts] //// + +=== numericCompoundAssignmentInForUpdateAfterExcludedZero.ts === +function shift(bitmap: number) { +>shift : (bitmap: number) => void +>bitmap : number + + for (let index = 0; bitmap !== 0; index++, bitmap >>>= 1) {} +>index : number +>0 : 0 +>bitmap !== 0 : boolean +>bitmap : number +>0 : 0 +>index++, bitmap >>>= 1 : number +>index++ : number +>index : number +>bitmap >>>= 1 : number +>bitmap : number +>1 : 1 +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInWhileLoopAfterExcludedZero.js b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInWhileLoopAfterExcludedZero.js new file mode 100644 index 0000000000000..7ee895202aa64 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInWhileLoopAfterExcludedZero.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/numericCompoundAssignmentInWhileLoopAfterExcludedZero.ts] //// + +//// [numericCompoundAssignmentInWhileLoopAfterExcludedZero.ts] +function rewind(index: number) { + while (index !== 0) { + index -= 1; + } +} + + +//// [numericCompoundAssignmentInWhileLoopAfterExcludedZero.js] +"use strict"; +function rewind(index) { + while (index !== 0) { + index -= 1; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInWhileLoopAfterExcludedZero.symbols b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInWhileLoopAfterExcludedZero.symbols new file mode 100644 index 0000000000000..4baad52f28f2a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInWhileLoopAfterExcludedZero.symbols @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/numericCompoundAssignmentInWhileLoopAfterExcludedZero.ts] //// + +=== numericCompoundAssignmentInWhileLoopAfterExcludedZero.ts === +function rewind(index: number) { +>rewind : Symbol(rewind, Decl(numericCompoundAssignmentInWhileLoopAfterExcludedZero.ts, 0, 0)) +>index : Symbol(index, Decl(numericCompoundAssignmentInWhileLoopAfterExcludedZero.ts, 0, 16)) + + while (index !== 0) { +>index : Symbol(index, Decl(numericCompoundAssignmentInWhileLoopAfterExcludedZero.ts, 0, 16)) + + index -= 1; +>index : Symbol(index, Decl(numericCompoundAssignmentInWhileLoopAfterExcludedZero.ts, 0, 16)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInWhileLoopAfterExcludedZero.types b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInWhileLoopAfterExcludedZero.types new file mode 100644 index 0000000000000..0d78ee80086fb --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentInWhileLoopAfterExcludedZero.types @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/numericCompoundAssignmentInWhileLoopAfterExcludedZero.ts] //// + +=== numericCompoundAssignmentInWhileLoopAfterExcludedZero.ts === +function rewind(index: number) { +>rewind : (index: number) => void +>index : number + + while (index !== 0) { +>index !== 0 : boolean +>index : number +>0 : 0 + + index -= 1; +>index -= 1 : number +>index : number +>1 : 1 + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsAfterConjunction.js b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsAfterConjunction.js new file mode 100644 index 0000000000000..c08b89db1bacd --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsAfterConjunction.js @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/numericCompoundAssignmentsAfterConjunction.ts] //// + +//// [numericCompoundAssignmentsAfterConjunction.ts] +function scale(left: number, right: number) { + if (left !== 0 && right !== 0) { + left *= -1.5; + right *= -1.5; + } else if (left !== 0) { + left *= -2; + } else if (right !== 0) { + right *= -2; + } +} + + +//// [numericCompoundAssignmentsAfterConjunction.js] +"use strict"; +function scale(left, right) { + if (left !== 0 && right !== 0) { + left *= -1.5; + right *= -1.5; + } + else if (left !== 0) { + left *= -2; + } + else if (right !== 0) { + right *= -2; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsAfterConjunction.symbols b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsAfterConjunction.symbols new file mode 100644 index 0000000000000..fad4cce4d0fa7 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsAfterConjunction.symbols @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/numericCompoundAssignmentsAfterConjunction.ts] //// + +=== numericCompoundAssignmentsAfterConjunction.ts === +function scale(left: number, right: number) { +>scale : Symbol(scale, Decl(numericCompoundAssignmentsAfterConjunction.ts, 0, 0)) +>left : Symbol(left, Decl(numericCompoundAssignmentsAfterConjunction.ts, 0, 15)) +>right : Symbol(right, Decl(numericCompoundAssignmentsAfterConjunction.ts, 0, 28)) + + if (left !== 0 && right !== 0) { +>left : Symbol(left, Decl(numericCompoundAssignmentsAfterConjunction.ts, 0, 15)) +>right : Symbol(right, Decl(numericCompoundAssignmentsAfterConjunction.ts, 0, 28)) + + left *= -1.5; +>left : Symbol(left, Decl(numericCompoundAssignmentsAfterConjunction.ts, 0, 15)) + + right *= -1.5; +>right : Symbol(right, Decl(numericCompoundAssignmentsAfterConjunction.ts, 0, 28)) + + } else if (left !== 0) { +>left : Symbol(left, Decl(numericCompoundAssignmentsAfterConjunction.ts, 0, 15)) + + left *= -2; +>left : Symbol(left, Decl(numericCompoundAssignmentsAfterConjunction.ts, 0, 15)) + + } else if (right !== 0) { +>right : Symbol(right, Decl(numericCompoundAssignmentsAfterConjunction.ts, 0, 28)) + + right *= -2; +>right : Symbol(right, Decl(numericCompoundAssignmentsAfterConjunction.ts, 0, 28)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsAfterConjunction.types b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsAfterConjunction.types new file mode 100644 index 0000000000000..e049be1be5520 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsAfterConjunction.types @@ -0,0 +1,53 @@ +//// [tests/cases/compiler/numericCompoundAssignmentsAfterConjunction.ts] //// + +=== numericCompoundAssignmentsAfterConjunction.ts === +function scale(left: number, right: number) { +>scale : (left: number, right: number) => void +>left : number +>right : number + + if (left !== 0 && right !== 0) { +>left !== 0 && right !== 0 : boolean +>left !== 0 : boolean +>left : number +>0 : 0 +>right !== 0 : boolean +>right : number +>0 : 0 + + left *= -1.5; +>left *= -1.5 : number +>left : number +>-1.5 : -1.5 +>1.5 : 1.5 + + right *= -1.5; +>right *= -1.5 : number +>right : number +>-1.5 : -1.5 +>1.5 : 1.5 + + } else if (left !== 0) { +>left !== 0 : boolean +>left : number +>0 : 0 + + left *= -2; +>left *= -2 : number +>left : number +>-2 : -2 +>2 : 2 + + } else if (right !== 0) { +>right !== 0 : boolean +>right : number +>0 : 0 + + right *= -2; +>right *= -2 : number +>right : number +>-2 : -2 +>2 : 2 + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsInNonzeroBranch.js b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsInNonzeroBranch.js new file mode 100644 index 0000000000000..95e27a445d2bc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsInNonzeroBranch.js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/numericCompoundAssignmentsInNonzeroBranch.ts] //// + +//// [numericCompoundAssignmentsInNonzeroBranch.ts] +function scale(value: number, factor: number) { + if (value !== 0) { + value *= -1; + value *= factor; + } +} + + +//// [numericCompoundAssignmentsInNonzeroBranch.js] +"use strict"; +function scale(value, factor) { + if (value !== 0) { + value *= -1; + value *= factor; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsInNonzeroBranch.symbols b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsInNonzeroBranch.symbols new file mode 100644 index 0000000000000..a23ca75d97764 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsInNonzeroBranch.symbols @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/numericCompoundAssignmentsInNonzeroBranch.ts] //// + +=== numericCompoundAssignmentsInNonzeroBranch.ts === +function scale(value: number, factor: number) { +>scale : Symbol(scale, Decl(numericCompoundAssignmentsInNonzeroBranch.ts, 0, 0)) +>value : Symbol(value, Decl(numericCompoundAssignmentsInNonzeroBranch.ts, 0, 15)) +>factor : Symbol(factor, Decl(numericCompoundAssignmentsInNonzeroBranch.ts, 0, 29)) + + if (value !== 0) { +>value : Symbol(value, Decl(numericCompoundAssignmentsInNonzeroBranch.ts, 0, 15)) + + value *= -1; +>value : Symbol(value, Decl(numericCompoundAssignmentsInNonzeroBranch.ts, 0, 15)) + + value *= factor; +>value : Symbol(value, Decl(numericCompoundAssignmentsInNonzeroBranch.ts, 0, 15)) +>factor : Symbol(factor, Decl(numericCompoundAssignmentsInNonzeroBranch.ts, 0, 29)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsInNonzeroBranch.types b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsInNonzeroBranch.types new file mode 100644 index 0000000000000..c4ae0b071a6dc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericCompoundAssignmentsInNonzeroBranch.types @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/numericCompoundAssignmentsInNonzeroBranch.ts] //// + +=== numericCompoundAssignmentsInNonzeroBranch.ts === +function scale(value: number, factor: number) { +>scale : (value: number, factor: number) => void +>value : number +>factor : number + + if (value !== 0) { +>value !== 0 : boolean +>value : number +>0 : 0 + + value *= -1; +>value *= -1 : number +>value : number +>-1 : -1 +>1 : 1 + + value *= factor; +>value *= factor : number +>value : number +>factor : number + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericPropertyCompoundAssignmentAfterDisjunction.js b/tsc/testdata/baselines/reference/compiler/numericPropertyCompoundAssignmentAfterDisjunction.js new file mode 100644 index 0000000000000..842869d40c63a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericPropertyCompoundAssignmentAfterDisjunction.js @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/numericPropertyCompoundAssignmentAfterDisjunction.ts] //// + +//// [numericPropertyCompoundAssignmentAfterDisjunction.ts] +class Decoder { + remaining = 0; + consume(size: number) { + if (this.remaining === 0 || size === 0) return; + this.remaining -= size; + } +} + + +//// [numericPropertyCompoundAssignmentAfterDisjunction.js] +"use strict"; +class Decoder { + remaining = 0; + consume(size) { + if (this.remaining === 0 || size === 0) + return; + this.remaining -= size; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/numericPropertyCompoundAssignmentAfterDisjunction.symbols b/tsc/testdata/baselines/reference/compiler/numericPropertyCompoundAssignmentAfterDisjunction.symbols new file mode 100644 index 0000000000000..fe93dc94203d8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericPropertyCompoundAssignmentAfterDisjunction.symbols @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/numericPropertyCompoundAssignmentAfterDisjunction.ts] //// + +=== numericPropertyCompoundAssignmentAfterDisjunction.ts === +class Decoder { +>Decoder : Symbol(Decoder, Decl(numericPropertyCompoundAssignmentAfterDisjunction.ts, 0, 0)) + + remaining = 0; +>remaining : Symbol(Decoder.remaining, Decl(numericPropertyCompoundAssignmentAfterDisjunction.ts, 0, 15)) + + consume(size: number) { +>consume : Symbol(Decoder.consume, Decl(numericPropertyCompoundAssignmentAfterDisjunction.ts, 1, 18)) +>size : Symbol(size, Decl(numericPropertyCompoundAssignmentAfterDisjunction.ts, 2, 12)) + + if (this.remaining === 0 || size === 0) return; +>this.remaining : Symbol(Decoder.remaining, Decl(numericPropertyCompoundAssignmentAfterDisjunction.ts, 0, 15)) +>this : Symbol(Decoder, Decl(numericPropertyCompoundAssignmentAfterDisjunction.ts, 0, 0)) +>remaining : Symbol(Decoder.remaining, Decl(numericPropertyCompoundAssignmentAfterDisjunction.ts, 0, 15)) +>size : Symbol(size, Decl(numericPropertyCompoundAssignmentAfterDisjunction.ts, 2, 12)) + + this.remaining -= size; +>this.remaining : Symbol(Decoder.remaining, Decl(numericPropertyCompoundAssignmentAfterDisjunction.ts, 0, 15)) +>this : Symbol(Decoder, Decl(numericPropertyCompoundAssignmentAfterDisjunction.ts, 0, 0)) +>remaining : Symbol(Decoder.remaining, Decl(numericPropertyCompoundAssignmentAfterDisjunction.ts, 0, 15)) +>size : Symbol(size, Decl(numericPropertyCompoundAssignmentAfterDisjunction.ts, 2, 12)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/numericPropertyCompoundAssignmentAfterDisjunction.types b/tsc/testdata/baselines/reference/compiler/numericPropertyCompoundAssignmentAfterDisjunction.types new file mode 100644 index 0000000000000..e44d3de070c02 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/numericPropertyCompoundAssignmentAfterDisjunction.types @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/numericPropertyCompoundAssignmentAfterDisjunction.ts] //// + +=== numericPropertyCompoundAssignmentAfterDisjunction.ts === +class Decoder { +>Decoder : Decoder + + remaining = 0; +>remaining : number +>0 : 0 + + consume(size: number) { +>consume : (size: number) => void +>size : number + + if (this.remaining === 0 || size === 0) return; +>this.remaining === 0 || size === 0 : boolean +>this.remaining === 0 : boolean +>this.remaining : number +>this : this +>remaining : number +>0 : 0 +>size === 0 : boolean +>size : number +>0 : 0 + + this.remaining -= size; +>this.remaining -= size : number +>this.remaining : number +>this : this +>remaining : number +>size : number + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/objectEntriesGenericMappedValues.js b/tsc/testdata/baselines/reference/compiler/objectEntriesGenericMappedValues.js new file mode 100644 index 0000000000000..f3b064663df03 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectEntriesGenericMappedValues.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/objectEntriesGenericMappedValues.ts] //// + +//// [objectEntriesGenericMappedValues.ts] +function read(attributes: Partial) { + const [, value] = Object.entries(attributes)[0]; + Object.entries(value); + const tabIndex: number = value; +} + + +//// [objectEntriesGenericMappedValues.js] +"use strict"; +function read(attributes) { + const [, value] = Object.entries(attributes)[0]; + Object.entries(value); + const tabIndex = value; +} diff --git a/tsc/testdata/baselines/reference/compiler/objectEntriesGenericMappedValues.symbols b/tsc/testdata/baselines/reference/compiler/objectEntriesGenericMappedValues.symbols new file mode 100644 index 0000000000000..2e99e1e18173a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectEntriesGenericMappedValues.symbols @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/objectEntriesGenericMappedValues.ts] //// + +=== objectEntriesGenericMappedValues.ts === +function read(attributes: Partial) { +>read : Symbol(read, Decl(objectEntriesGenericMappedValues.ts, 0, 0)) +>T : Symbol(T, Decl(objectEntriesGenericMappedValues.ts, 0, 14)) +>tabIndex : Symbol(tabIndex, Decl(objectEntriesGenericMappedValues.ts, 0, 25)) +>attributes : Symbol(attributes, Decl(objectEntriesGenericMappedValues.ts, 0, 46)) +>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(objectEntriesGenericMappedValues.ts, 0, 14)) + + const [, value] = Object.entries(attributes)[0]; +>value : Symbol(value, Decl(objectEntriesGenericMappedValues.ts, 1, 12)) +>Object.entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>attributes : Symbol(attributes, Decl(objectEntriesGenericMappedValues.ts, 0, 46)) + + Object.entries(value); +>Object.entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>value : Symbol(value, Decl(objectEntriesGenericMappedValues.ts, 1, 12)) + + const tabIndex: number = value; +>tabIndex : Symbol(tabIndex, Decl(objectEntriesGenericMappedValues.ts, 3, 9)) +>value : Symbol(value, Decl(objectEntriesGenericMappedValues.ts, 1, 12)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/objectEntriesGenericMappedValues.types b/tsc/testdata/baselines/reference/compiler/objectEntriesGenericMappedValues.types new file mode 100644 index 0000000000000..12fcc648abd4b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectEntriesGenericMappedValues.types @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/objectEntriesGenericMappedValues.ts] //// + +=== objectEntriesGenericMappedValues.ts === +function read(attributes: Partial) { +>read : (attributes: Partial) => void +>tabIndex : number +>attributes : Partial + + const [, value] = Object.entries(attributes)[0]; +>value : any +>Object.entries(attributes)[0] : [string, any] +>Object.entries(attributes) : [string, any][] +>Object.entries : { (o: { [s: string]: T_1; } | ArrayLike): [string, T_1][]; (o: {}): [string, any][]; } +>Object : ObjectConstructor +>entries : { (o: { [s: string]: T_1; } | ArrayLike): [string, T_1][]; (o: {}): [string, any][]; } +>attributes : Partial +>0 : 0 + + Object.entries(value); +>Object.entries(value) : [string, unknown][] +>Object.entries : { (o: { [s: string]: T_1; } | ArrayLike): [string, T_1][]; (o: {}): [string, any][]; } +>Object : ObjectConstructor +>entries : { (o: { [s: string]: T_1; } | ArrayLike): [string, T_1][]; (o: {}): [string, any][]; } +>value : any + + const tabIndex: number = value; +>tabIndex : number +>value : any +} + diff --git a/tsc/testdata/baselines/reference/compiler/objectEntriesMapBroadKeyLookup.js b/tsc/testdata/baselines/reference/compiler/objectEntriesMapBroadKeyLookup.js new file mode 100644 index 0000000000000..ef82e6f2e88fc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectEntriesMapBroadKeyLookup.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/objectEntriesMapBroadKeyLookup.ts] //// + +//// [objectEntriesMapBroadKeyLookup.ts] +declare const languages: Record<"en" | "fr", string>; +declare const language: string; + +new Map(Object.entries(languages)).get(language); + + +//// [objectEntriesMapBroadKeyLookup.js] +"use strict"; +new Map(Object.entries(languages)).get(language); diff --git a/tsc/testdata/baselines/reference/compiler/objectEntriesMapBroadKeyLookup.symbols b/tsc/testdata/baselines/reference/compiler/objectEntriesMapBroadKeyLookup.symbols new file mode 100644 index 0000000000000..9977a864a467a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectEntriesMapBroadKeyLookup.symbols @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/objectEntriesMapBroadKeyLookup.ts] //// + +=== objectEntriesMapBroadKeyLookup.ts === +declare const languages: Record<"en" | "fr", string>; +>languages : Symbol(languages, Decl(objectEntriesMapBroadKeyLookup.ts, 0, 13)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + +declare const language: string; +>language : Symbol(language, Decl(objectEntriesMapBroadKeyLookup.ts, 1, 13)) + +new Map(Object.entries(languages)).get(language); +>new Map(Object.entries(languages)).get : Symbol(Map.get, Decl(lib.es2015.collection.d.ts, --, --)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>Object.entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>languages : Symbol(languages, Decl(objectEntriesMapBroadKeyLookup.ts, 0, 13)) +>get : Symbol(Map.get, Decl(lib.es2015.collection.d.ts, --, --)) +>language : Symbol(language, Decl(objectEntriesMapBroadKeyLookup.ts, 1, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/objectEntriesMapBroadKeyLookup.types b/tsc/testdata/baselines/reference/compiler/objectEntriesMapBroadKeyLookup.types new file mode 100644 index 0000000000000..c650634a3e02b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectEntriesMapBroadKeyLookup.types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/objectEntriesMapBroadKeyLookup.ts] //// + +=== objectEntriesMapBroadKeyLookup.ts === +declare const languages: Record<"en" | "fr", string>; +>languages : Record<"en" | "fr", string> + +declare const language: string; +>language : string + +new Map(Object.entries(languages)).get(language); +>new Map(Object.entries(languages)).get(language) : string | undefined +>new Map(Object.entries(languages)).get : (key: string) => string | undefined +>new Map(Object.entries(languages)) : Map +>Map : MapConstructor +>Object.entries(languages) : [string, string][] +>Object.entries : { (o: { [s: string]: T; } | ArrayLike): [string, T][]; (o: {}): [string, any][]; } +>Object : ObjectConstructor +>entries : { (o: { [s: string]: T; } | ArrayLike): [string, T][]; (o: {}): [string, any][]; } +>languages : Record<"en" | "fr", string> +>get : (key: string) => string | undefined +>language : string + diff --git a/tsc/testdata/baselines/reference/compiler/objectEntriesObjectArrayNarrowing.js b/tsc/testdata/baselines/reference/compiler/objectEntriesObjectArrayNarrowing.js new file mode 100644 index 0000000000000..a390fd1b72f27 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectEntriesObjectArrayNarrowing.js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/objectEntriesObjectArrayNarrowing.ts] //// + +//// [objectEntriesObjectArrayNarrowing.ts] +declare const record: object; +for (const [, value] of Object.entries(record)) { + if (Array.isArray(value)) { + value.forEach(() => {}); + } +} + + +//// [objectEntriesObjectArrayNarrowing.js] +"use strict"; +for (const [, value] of Object.entries(record)) { + if (Array.isArray(value)) { + value.forEach(() => { }); + } +} diff --git a/tsc/testdata/baselines/reference/compiler/objectEntriesObjectArrayNarrowing.symbols b/tsc/testdata/baselines/reference/compiler/objectEntriesObjectArrayNarrowing.symbols new file mode 100644 index 0000000000000..573801e00db50 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectEntriesObjectArrayNarrowing.symbols @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/objectEntriesObjectArrayNarrowing.ts] //// + +=== objectEntriesObjectArrayNarrowing.ts === +declare const record: object; +>record : Symbol(record, Decl(objectEntriesObjectArrayNarrowing.ts, 0, 13)) + +for (const [, value] of Object.entries(record)) { +>value : Symbol(value, Decl(objectEntriesObjectArrayNarrowing.ts, 1, 13)) +>Object.entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>record : Symbol(record, Decl(objectEntriesObjectArrayNarrowing.ts, 0, 13)) + + if (Array.isArray(value)) { +>Array.isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 1 more) +>isArray : Symbol(ArrayConstructor.isArray, Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(objectEntriesObjectArrayNarrowing.ts, 1, 13)) + + value.forEach(() => {}); +>value.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>value : Symbol(value, Decl(objectEntriesObjectArrayNarrowing.ts, 1, 13)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/objectEntriesObjectArrayNarrowing.types b/tsc/testdata/baselines/reference/compiler/objectEntriesObjectArrayNarrowing.types new file mode 100644 index 0000000000000..98ae6838036f8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectEntriesObjectArrayNarrowing.types @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/objectEntriesObjectArrayNarrowing.ts] //// + +=== objectEntriesObjectArrayNarrowing.ts === +declare const record: object; +>record : object + +for (const [, value] of Object.entries(record)) { +>value : any +>Object.entries(record) : [string, any][] +>Object.entries : { (o: { [s: string]: T; } | ArrayLike): [string, T][]; (o: {}): [string, any][]; } +>Object : ObjectConstructor +>entries : { (o: { [s: string]: T; } | ArrayLike): [string, T][]; (o: {}): [string, any][]; } +>record : object + + if (Array.isArray(value)) { +>Array.isArray(value) : boolean +>Array.isArray : (arg: any) => arg is any[] +>Array : ArrayConstructor +>isArray : (arg: any) => arg is any[] +>value : any + + value.forEach(() => {}); +>value.forEach(() => {}) : void +>value.forEach : (callbackfn: (value: any, index: number, array: any[]) => void, thisArg?: any) => void +>value : any[] +>forEach : (callbackfn: (value: any, index: number, array: any[]) => void, thisArg?: any) => void +>() => {} : () => void + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/objectEntriesPartialIndexedWrite.js b/tsc/testdata/baselines/reference/compiler/objectEntriesPartialIndexedWrite.js new file mode 100644 index 0000000000000..c0a29c9aa01c0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectEntriesPartialIndexedWrite.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/objectEntriesPartialIndexedWrite.ts] //// + +//// [objectEntriesPartialIndexedWrite.ts] +type Row = { amount: number } & Record; +export function copy(row: Row, mapping: { amount: string; notes: string }) { + const result: Partial = {}; + for (const [field, target] of Object.entries(mapping)) { + result[field] = row[target]; + } + return result; +} + + +//// [objectEntriesPartialIndexedWrite.js] +export function copy(row, mapping) { + const result = {}; + for (const [field, target] of Object.entries(mapping)) { + result[field] = row[target]; + } + return result; +} diff --git a/tsc/testdata/baselines/reference/compiler/objectEntriesPartialIndexedWrite.symbols b/tsc/testdata/baselines/reference/compiler/objectEntriesPartialIndexedWrite.symbols new file mode 100644 index 0000000000000..22d67fa529098 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectEntriesPartialIndexedWrite.symbols @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/objectEntriesPartialIndexedWrite.ts] //// + +=== objectEntriesPartialIndexedWrite.ts === +type Row = { amount: number } & Record; +>Row : Symbol(Row, Decl(objectEntriesPartialIndexedWrite.ts, 0, 0)) +>amount : Symbol(amount, Decl(objectEntriesPartialIndexedWrite.ts, 0, 12)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + +export function copy(row: Row, mapping: { amount: string; notes: string }) { +>copy : Symbol(copy, Decl(objectEntriesPartialIndexedWrite.ts, 0, 55)) +>row : Symbol(row, Decl(objectEntriesPartialIndexedWrite.ts, 1, 21)) +>Row : Symbol(Row, Decl(objectEntriesPartialIndexedWrite.ts, 0, 0)) +>mapping : Symbol(mapping, Decl(objectEntriesPartialIndexedWrite.ts, 1, 30)) +>amount : Symbol(amount, Decl(objectEntriesPartialIndexedWrite.ts, 1, 41)) +>notes : Symbol(notes, Decl(objectEntriesPartialIndexedWrite.ts, 1, 57)) + + const result: Partial = {}; +>result : Symbol(result, Decl(objectEntriesPartialIndexedWrite.ts, 2, 9)) +>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) +>Row : Symbol(Row, Decl(objectEntriesPartialIndexedWrite.ts, 0, 0)) + + for (const [field, target] of Object.entries(mapping)) { +>field : Symbol(field, Decl(objectEntriesPartialIndexedWrite.ts, 3, 16)) +>target : Symbol(target, Decl(objectEntriesPartialIndexedWrite.ts, 3, 22)) +>Object.entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>mapping : Symbol(mapping, Decl(objectEntriesPartialIndexedWrite.ts, 1, 30)) + + result[field] = row[target]; +>result : Symbol(result, Decl(objectEntriesPartialIndexedWrite.ts, 2, 9)) +>field : Symbol(field, Decl(objectEntriesPartialIndexedWrite.ts, 3, 16)) +>row : Symbol(row, Decl(objectEntriesPartialIndexedWrite.ts, 1, 21)) +>target : Symbol(target, Decl(objectEntriesPartialIndexedWrite.ts, 3, 22)) + } + return result; +>result : Symbol(result, Decl(objectEntriesPartialIndexedWrite.ts, 2, 9)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/objectEntriesPartialIndexedWrite.types b/tsc/testdata/baselines/reference/compiler/objectEntriesPartialIndexedWrite.types new file mode 100644 index 0000000000000..89a685315a29c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectEntriesPartialIndexedWrite.types @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/objectEntriesPartialIndexedWrite.ts] //// + +=== objectEntriesPartialIndexedWrite.ts === +type Row = { amount: number } & Record; +>Row : Row +>amount : number + +export function copy(row: Row, mapping: { amount: string; notes: string }) { +>copy : (row: Row, mapping: { amount: string; notes: string; }) => Partial +>row : Row +>mapping : { amount: string; notes: string; } +>amount : string +>notes : string + + const result: Partial = {}; +>result : Partial +>{} : {} + + for (const [field, target] of Object.entries(mapping)) { +>field : string +>target : string +>Object.entries(mapping) : [string, string][] +>Object.entries : { (o: { [s: string]: T; } | ArrayLike): [string, T][]; (o: {}): [string, any][]; } +>Object : ObjectConstructor +>entries : { (o: { [s: string]: T; } | ArrayLike): [string, T][]; (o: {}): [string, any][]; } +>mapping : { amount: string; notes: string; } + + result[field] = row[target]; +>result[field] = row[target] : string +>result[field] : string +>result : Partial +>field : string +>row[target] : string +>row : Row +>target : string + } + return result; +>result : Partial +} + diff --git a/tsc/testdata/baselines/reference/compiler/objectEntriesSymbolValueArity.js b/tsc/testdata/baselines/reference/compiler/objectEntriesSymbolValueArity.js new file mode 100644 index 0000000000000..23bd0e230e6bd --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectEntriesSymbolValueArity.js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/objectEntriesSymbolValueArity.ts] //// + +//// [objectEntriesSymbolValueArity.ts] +declare const database: unique symbol; +declare const models: { + user: { create(entity?: object): void }; + [database]: { create(name: string, entity: object, id?: string): void }; +}; + +for (const [, model] of Object.entries(models)) { + model.create({}); +} + + +//// [objectEntriesSymbolValueArity.js] +"use strict"; +for (const [, model] of Object.entries(models)) { + model.create({}); +} diff --git a/tsc/testdata/baselines/reference/compiler/objectEntriesSymbolValueArity.symbols b/tsc/testdata/baselines/reference/compiler/objectEntriesSymbolValueArity.symbols new file mode 100644 index 0000000000000..afe2682939b83 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectEntriesSymbolValueArity.symbols @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/objectEntriesSymbolValueArity.ts] //// + +=== objectEntriesSymbolValueArity.ts === +declare const database: unique symbol; +>database : Symbol(database, Decl(objectEntriesSymbolValueArity.ts, 0, 13)) + +declare const models: { +>models : Symbol(models, Decl(objectEntriesSymbolValueArity.ts, 1, 13)) + + user: { create(entity?: object): void }; +>user : Symbol(user, Decl(objectEntriesSymbolValueArity.ts, 1, 23)) +>create : Symbol(create, Decl(objectEntriesSymbolValueArity.ts, 2, 11)) +>entity : Symbol(entity, Decl(objectEntriesSymbolValueArity.ts, 2, 19)) + + [database]: { create(name: string, entity: object, id?: string): void }; +>[database] : Symbol([database], Decl(objectEntriesSymbolValueArity.ts, 2, 44)) +>database : Symbol(database, Decl(objectEntriesSymbolValueArity.ts, 0, 13)) +>create : Symbol(create, Decl(objectEntriesSymbolValueArity.ts, 3, 17)) +>name : Symbol(name, Decl(objectEntriesSymbolValueArity.ts, 3, 25)) +>entity : Symbol(entity, Decl(objectEntriesSymbolValueArity.ts, 3, 38)) +>id : Symbol(id, Decl(objectEntriesSymbolValueArity.ts, 3, 54)) + +}; + +for (const [, model] of Object.entries(models)) { +>model : Symbol(model, Decl(objectEntriesSymbolValueArity.ts, 6, 13)) +>Object.entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>models : Symbol(models, Decl(objectEntriesSymbolValueArity.ts, 1, 13)) + + model.create({}); +>model.create : Symbol(create, Decl(objectEntriesSymbolValueArity.ts, 2, 11)) +>model : Symbol(model, Decl(objectEntriesSymbolValueArity.ts, 6, 13)) +>create : Symbol(create, Decl(objectEntriesSymbolValueArity.ts, 2, 11)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/objectEntriesSymbolValueArity.types b/tsc/testdata/baselines/reference/compiler/objectEntriesSymbolValueArity.types new file mode 100644 index 0000000000000..2c6c28c5ee395 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectEntriesSymbolValueArity.types @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/objectEntriesSymbolValueArity.ts] //// + +=== objectEntriesSymbolValueArity.ts === +declare const database: unique symbol; +>database : unique symbol + +declare const models: { +>models : { user: { create(entity?: object): void; }; [database]: { create(name: string, entity: object, id?: string): void; }; } + + user: { create(entity?: object): void }; +>user : { create(entity?: object): void; } +>create : (entity?: object) => void +>entity : object | undefined + + [database]: { create(name: string, entity: object, id?: string): void }; +>[database] : { create(name: string, entity: object, id?: string): void; } +>database : unique symbol +>create : (name: string, entity: object, id?: string) => void +>name : string +>entity : object +>id : string | undefined + +}; + +for (const [, model] of Object.entries(models)) { +>model : { create(entity?: object): void; } +>Object.entries(models) : [string, { create(entity?: object): void; }][] +>Object.entries : { (o: { [s: string]: T; } | ArrayLike): [string, T][]; (o: {}): [string, any][]; } +>Object : ObjectConstructor +>entries : { (o: { [s: string]: T; } | ArrayLike): [string, T][]; (o: {}): [string, any][]; } +>models : { user: { create(entity?: object): void; }; [database]: { create(name: string, entity: object, id?: string): void; }; } + + model.create({}); +>model.create({}) : void +>model.create : (entity?: object) => void +>model : { create(entity?: object): void; } +>create : (entity?: object) => void +>{} : {} +} + diff --git a/tsc/testdata/baselines/reference/compiler/objectFromEntriesAdditionalProperty.js b/tsc/testdata/baselines/reference/compiler/objectFromEntriesAdditionalProperty.js new file mode 100644 index 0000000000000..106270a93abb6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectFromEntriesAdditionalProperty.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/objectFromEntriesAdditionalProperty.ts] //// + +//// [objectFromEntriesAdditionalProperty.ts] +declare const keys: ("language" | "theme")[]; +const settings = Object.fromEntries(keys.map(key => [key, ""])); +settings.timestamp = ""; + + +//// [objectFromEntriesAdditionalProperty.js] +"use strict"; +const settings = Object.fromEntries(keys.map(key => [key, ""])); +settings.timestamp = ""; diff --git a/tsc/testdata/baselines/reference/compiler/objectFromEntriesAdditionalProperty.symbols b/tsc/testdata/baselines/reference/compiler/objectFromEntriesAdditionalProperty.symbols new file mode 100644 index 0000000000000..04abbfc6e0321 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectFromEntriesAdditionalProperty.symbols @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/objectFromEntriesAdditionalProperty.ts] //// + +=== objectFromEntriesAdditionalProperty.ts === +declare const keys: ("language" | "theme")[]; +>keys : Symbol(keys, Decl(objectFromEntriesAdditionalProperty.ts, 0, 13)) + +const settings = Object.fromEntries(keys.map(key => [key, ""])); +>settings : Symbol(settings, Decl(objectFromEntriesAdditionalProperty.ts, 1, 5)) +>Object.fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) +>keys.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>keys : Symbol(keys, Decl(objectFromEntriesAdditionalProperty.ts, 0, 13)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>key : Symbol(key, Decl(objectFromEntriesAdditionalProperty.ts, 1, 45)) +>key : Symbol(key, Decl(objectFromEntriesAdditionalProperty.ts, 1, 45)) + +settings.timestamp = ""; +>settings.timestamp : Symbol(__index, Decl(lib.es2019.object.d.ts, --, --)) +>settings : Symbol(settings, Decl(objectFromEntriesAdditionalProperty.ts, 1, 5)) +>timestamp : Symbol(__index, Decl(lib.es2019.object.d.ts, --, --)) + diff --git a/tsc/testdata/baselines/reference/compiler/objectFromEntriesAdditionalProperty.types b/tsc/testdata/baselines/reference/compiler/objectFromEntriesAdditionalProperty.types new file mode 100644 index 0000000000000..37e5aba1baf7e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectFromEntriesAdditionalProperty.types @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/objectFromEntriesAdditionalProperty.ts] //// + +=== objectFromEntriesAdditionalProperty.ts === +declare const keys: ("language" | "theme")[]; +>keys : ("language" | "theme")[] + +const settings = Object.fromEntries(keys.map(key => [key, ""])); +>settings : { [k: string]: string; } +>Object.fromEntries(keys.map(key => [key, ""])) : { [k: string]: string; } +>Object.fromEntries : { (entries: Iterable): { [k: string]: T; }; (entries: Iterable): any; } +>Object : ObjectConstructor +>fromEntries : { (entries: Iterable): { [k: string]: T; }; (entries: Iterable): any; } +>keys.map(key => [key, ""]) : ["language" | "theme", string][] +>keys.map : (callbackfn: (value: "language" | "theme", index: number, array: ("language" | "theme")[]) => U, thisArg?: any) => U[] +>keys : ("language" | "theme")[] +>map : (callbackfn: (value: "language" | "theme", index: number, array: ("language" | "theme")[]) => U, thisArg?: any) => U[] +>key => [key, ""] : (key: "language" | "theme") => ["language" | "theme", string] +>key : "language" | "theme" +>[key, ""] : ["language" | "theme", string] +>key : "language" | "theme" +>"" : "" + +settings.timestamp = ""; +>settings.timestamp = "" : "" +>settings.timestamp : string +>settings : { [k: string]: string; } +>timestamp : string +>"" : "" + diff --git a/tsc/testdata/baselines/reference/compiler/objectFromEntriesBrandedTemplateKeys.js b/tsc/testdata/baselines/reference/compiler/objectFromEntriesBrandedTemplateKeys.js new file mode 100644 index 0000000000000..532bf75270587 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectFromEntriesBrandedTemplateKeys.js @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/objectFromEntriesBrandedTemplateKeys.ts] //// + +//// [objectFromEntriesBrandedTemplateKeys.ts] +type FeatureId = string & { feature: true }; +declare const featureIds: FeatureId[]; +const options = Object.fromEntries(featureIds.map(id => [`feature:${id}`, true])); +declare const featureName: string; + +options[`feature:${featureName}`]; +featureIds.filter(id => options["feature:" + id]); +for (const [from, to] of Object.entries({ oldFeature: "newFeature" })) { + if (typeof options[`feature:${from}`] === "boolean") { + options[`feature:${to}`] = options[`feature:${from}`]; + } +} + + +//// [objectFromEntriesBrandedTemplateKeys.js] +"use strict"; +const options = Object.fromEntries(featureIds.map(id => [`feature:${id}`, true])); +options[`feature:${featureName}`]; +featureIds.filter(id => options["feature:" + id]); +for (const [from, to] of Object.entries({ oldFeature: "newFeature" })) { + if (typeof options[`feature:${from}`] === "boolean") { + options[`feature:${to}`] = options[`feature:${from}`]; + } +} diff --git a/tsc/testdata/baselines/reference/compiler/objectFromEntriesBrandedTemplateKeys.symbols b/tsc/testdata/baselines/reference/compiler/objectFromEntriesBrandedTemplateKeys.symbols new file mode 100644 index 0000000000000..0eb819503b8b3 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectFromEntriesBrandedTemplateKeys.symbols @@ -0,0 +1,57 @@ +//// [tests/cases/compiler/objectFromEntriesBrandedTemplateKeys.ts] //// + +=== objectFromEntriesBrandedTemplateKeys.ts === +type FeatureId = string & { feature: true }; +>FeatureId : Symbol(FeatureId, Decl(objectFromEntriesBrandedTemplateKeys.ts, 0, 0)) +>feature : Symbol(feature, Decl(objectFromEntriesBrandedTemplateKeys.ts, 0, 27)) + +declare const featureIds: FeatureId[]; +>featureIds : Symbol(featureIds, Decl(objectFromEntriesBrandedTemplateKeys.ts, 1, 13)) +>FeatureId : Symbol(FeatureId, Decl(objectFromEntriesBrandedTemplateKeys.ts, 0, 0)) + +const options = Object.fromEntries(featureIds.map(id => [`feature:${id}`, true])); +>options : Symbol(options, Decl(objectFromEntriesBrandedTemplateKeys.ts, 2, 5)) +>Object.fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) +>featureIds.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>featureIds : Symbol(featureIds, Decl(objectFromEntriesBrandedTemplateKeys.ts, 1, 13)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>id : Symbol(id, Decl(objectFromEntriesBrandedTemplateKeys.ts, 2, 50)) +>id : Symbol(id, Decl(objectFromEntriesBrandedTemplateKeys.ts, 2, 50)) + +declare const featureName: string; +>featureName : Symbol(featureName, Decl(objectFromEntriesBrandedTemplateKeys.ts, 3, 13)) + +options[`feature:${featureName}`]; +>options : Symbol(options, Decl(objectFromEntriesBrandedTemplateKeys.ts, 2, 5)) +>featureName : Symbol(featureName, Decl(objectFromEntriesBrandedTemplateKeys.ts, 3, 13)) + +featureIds.filter(id => options["feature:" + id]); +>featureIds.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>featureIds : Symbol(featureIds, Decl(objectFromEntriesBrandedTemplateKeys.ts, 1, 13)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>id : Symbol(id, Decl(objectFromEntriesBrandedTemplateKeys.ts, 6, 18)) +>options : Symbol(options, Decl(objectFromEntriesBrandedTemplateKeys.ts, 2, 5)) +>id : Symbol(id, Decl(objectFromEntriesBrandedTemplateKeys.ts, 6, 18)) + +for (const [from, to] of Object.entries({ oldFeature: "newFeature" })) { +>from : Symbol(from, Decl(objectFromEntriesBrandedTemplateKeys.ts, 7, 12)) +>to : Symbol(to, Decl(objectFromEntriesBrandedTemplateKeys.ts, 7, 17)) +>Object.entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>entries : Symbol(ObjectConstructor.entries, Decl(lib.es2017.object.d.ts, --, --), Decl(lib.es2017.object.d.ts, --, --)) +>oldFeature : Symbol(oldFeature, Decl(objectFromEntriesBrandedTemplateKeys.ts, 7, 41)) + + if (typeof options[`feature:${from}`] === "boolean") { +>options : Symbol(options, Decl(objectFromEntriesBrandedTemplateKeys.ts, 2, 5)) +>from : Symbol(from, Decl(objectFromEntriesBrandedTemplateKeys.ts, 7, 12)) + + options[`feature:${to}`] = options[`feature:${from}`]; +>options : Symbol(options, Decl(objectFromEntriesBrandedTemplateKeys.ts, 2, 5)) +>to : Symbol(to, Decl(objectFromEntriesBrandedTemplateKeys.ts, 7, 17)) +>options : Symbol(options, Decl(objectFromEntriesBrandedTemplateKeys.ts, 2, 5)) +>from : Symbol(from, Decl(objectFromEntriesBrandedTemplateKeys.ts, 7, 12)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/objectFromEntriesBrandedTemplateKeys.types b/tsc/testdata/baselines/reference/compiler/objectFromEntriesBrandedTemplateKeys.types new file mode 100644 index 0000000000000..7a209ef2d4ee0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectFromEntriesBrandedTemplateKeys.types @@ -0,0 +1,83 @@ +//// [tests/cases/compiler/objectFromEntriesBrandedTemplateKeys.ts] //// + +=== objectFromEntriesBrandedTemplateKeys.ts === +type FeatureId = string & { feature: true }; +>FeatureId : FeatureId +>feature : true +>true : true + +declare const featureIds: FeatureId[]; +>featureIds : FeatureId[] + +const options = Object.fromEntries(featureIds.map(id => [`feature:${id}`, true])); +>options : { [k: string]: boolean; } +>Object.fromEntries(featureIds.map(id => [`feature:${id}`, true])) : { [k: string]: boolean; } +>Object.fromEntries : { (entries: Iterable): { [k: string]: T; }; (entries: Iterable): any; } +>Object : ObjectConstructor +>fromEntries : { (entries: Iterable): { [k: string]: T; }; (entries: Iterable): any; } +>featureIds.map(id => [`feature:${id}`, true]) : [string, boolean][] +>featureIds.map : (callbackfn: (value: FeatureId, index: number, array: FeatureId[]) => U, thisArg?: any) => U[] +>featureIds : FeatureId[] +>map : (callbackfn: (value: FeatureId, index: number, array: FeatureId[]) => U, thisArg?: any) => U[] +>id => [`feature:${id}`, true] : (id: FeatureId) => [string, boolean] +>id : FeatureId +>[`feature:${id}`, true] : [string, true] +>`feature:${id}` : string +>id : FeatureId +>true : true + +declare const featureName: string; +>featureName : string + +options[`feature:${featureName}`]; +>options[`feature:${featureName}`] : boolean +>options : { [k: string]: boolean; } +>`feature:${featureName}` : `feature:${string}` +>featureName : string + +featureIds.filter(id => options["feature:" + id]); +>featureIds.filter(id => options["feature:" + id]) : FeatureId[] +>featureIds.filter : { (predicate: (value: FeatureId, index: number, array: FeatureId[]) => value is S, thisArg?: any): S[]; (predicate: (value: FeatureId, index: number, array: FeatureId[]) => unknown, thisArg?: any): FeatureId[]; } +>featureIds : FeatureId[] +>filter : { (predicate: (value: FeatureId, index: number, array: FeatureId[]) => value is S, thisArg?: any): S[]; (predicate: (value: FeatureId, index: number, array: FeatureId[]) => unknown, thisArg?: any): FeatureId[]; } +>id => options["feature:" + id] : (id: FeatureId) => boolean +>id : FeatureId +>options["feature:" + id] : boolean +>options : { [k: string]: boolean; } +>"feature:" + id : string +>"feature:" : "feature:" +>id : FeatureId + +for (const [from, to] of Object.entries({ oldFeature: "newFeature" })) { +>from : string +>to : string +>Object.entries({ oldFeature: "newFeature" }) : [string, string][] +>Object.entries : { (o: { [s: string]: T; } | ArrayLike): [string, T][]; (o: {}): [string, any][]; } +>Object : ObjectConstructor +>entries : { (o: { [s: string]: T; } | ArrayLike): [string, T][]; (o: {}): [string, any][]; } +>{ oldFeature: "newFeature" } : { oldFeature: string; } +>oldFeature : string +>"newFeature" : "newFeature" + + if (typeof options[`feature:${from}`] === "boolean") { +>typeof options[`feature:${from}`] === "boolean" : boolean +>typeof options[`feature:${from}`] : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" +>options[`feature:${from}`] : boolean +>options : { [k: string]: boolean; } +>`feature:${from}` : `feature:${string}` +>from : string +>"boolean" : "boolean" + + options[`feature:${to}`] = options[`feature:${from}`]; +>options[`feature:${to}`] = options[`feature:${from}`] : boolean +>options[`feature:${to}`] : boolean +>options : { [k: string]: boolean; } +>`feature:${to}` : `feature:${string}` +>to : string +>options[`feature:${from}`] : boolean +>options : { [k: string]: boolean; } +>`feature:${from}` : `feature:${string}` +>from : string + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/objectFromEntriesSpreadPossibleDuplicates.js b/tsc/testdata/baselines/reference/compiler/objectFromEntriesSpreadPossibleDuplicates.js new file mode 100644 index 0000000000000..d3b80fb322b83 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectFromEntriesSpreadPossibleDuplicates.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/objectFromEntriesSpreadPossibleDuplicates.ts] //// + +//// [objectFromEntriesSpreadPossibleDuplicates.ts] +declare const icons: { iconName: "bicycle" | "book" }[]; +export const mapping = { + bicycle: 0, + ...Object.fromEntries(icons.map(icon => [icon.iconName, 1])), +}; + + +//// [objectFromEntriesSpreadPossibleDuplicates.js] +export const mapping = { + bicycle: 0, + ...Object.fromEntries(icons.map(icon => [icon.iconName, 1])), +}; diff --git a/tsc/testdata/baselines/reference/compiler/objectFromEntriesSpreadPossibleDuplicates.symbols b/tsc/testdata/baselines/reference/compiler/objectFromEntriesSpreadPossibleDuplicates.symbols new file mode 100644 index 0000000000000..372daa391c854 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectFromEntriesSpreadPossibleDuplicates.symbols @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/objectFromEntriesSpreadPossibleDuplicates.ts] //// + +=== objectFromEntriesSpreadPossibleDuplicates.ts === +declare const icons: { iconName: "bicycle" | "book" }[]; +>icons : Symbol(icons, Decl(objectFromEntriesSpreadPossibleDuplicates.ts, 0, 13)) +>iconName : Symbol(iconName, Decl(objectFromEntriesSpreadPossibleDuplicates.ts, 0, 22)) + +export const mapping = { +>mapping : Symbol(mapping, Decl(objectFromEntriesSpreadPossibleDuplicates.ts, 1, 12)) + + bicycle: 0, +>bicycle : Symbol(bicycle, Decl(objectFromEntriesSpreadPossibleDuplicates.ts, 1, 24)) + + ...Object.fromEntries(icons.map(icon => [icon.iconName, 1])), +>Object.fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>fromEntries : Symbol(ObjectConstructor.fromEntries, Decl(lib.es2019.object.d.ts, --, --), Decl(lib.es2019.object.d.ts, --, --)) +>icons.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>icons : Symbol(icons, Decl(objectFromEntriesSpreadPossibleDuplicates.ts, 0, 13)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --)) +>icon : Symbol(icon, Decl(objectFromEntriesSpreadPossibleDuplicates.ts, 3, 36)) +>icon.iconName : Symbol(iconName, Decl(objectFromEntriesSpreadPossibleDuplicates.ts, 0, 22)) +>icon : Symbol(icon, Decl(objectFromEntriesSpreadPossibleDuplicates.ts, 3, 36)) +>iconName : Symbol(iconName, Decl(objectFromEntriesSpreadPossibleDuplicates.ts, 0, 22)) + +}; + diff --git a/tsc/testdata/baselines/reference/compiler/objectFromEntriesSpreadPossibleDuplicates.types b/tsc/testdata/baselines/reference/compiler/objectFromEntriesSpreadPossibleDuplicates.types new file mode 100644 index 0000000000000..9f37475f8d75c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/objectFromEntriesSpreadPossibleDuplicates.types @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/objectFromEntriesSpreadPossibleDuplicates.ts] //// + +=== objectFromEntriesSpreadPossibleDuplicates.ts === +declare const icons: { iconName: "bicycle" | "book" }[]; +>icons : { iconName: "bicycle" | "book"; }[] +>iconName : "bicycle" | "book" + +export const mapping = { +>mapping : { bicycle: number; } +>{ bicycle: 0, ...Object.fromEntries(icons.map(icon => [icon.iconName, 1])),} : { bicycle: number; } + + bicycle: 0, +>bicycle : number +>0 : 0 + + ...Object.fromEntries(icons.map(icon => [icon.iconName, 1])), +>Object.fromEntries(icons.map(icon => [icon.iconName, 1])) : { [k: string]: number; } +>Object.fromEntries : { (entries: Iterable): { [k: string]: T; }; (entries: Iterable): any; } +>Object : ObjectConstructor +>fromEntries : { (entries: Iterable): { [k: string]: T; }; (entries: Iterable): any; } +>icons.map(icon => [icon.iconName, 1]) : ["bicycle" | "book", number][] +>icons.map : (callbackfn: (value: { iconName: "bicycle" | "book"; }, index: number, array: { iconName: "bicycle" | "book"; }[]) => U, thisArg?: any) => U[] +>icons : { iconName: "bicycle" | "book"; }[] +>map : (callbackfn: (value: { iconName: "bicycle" | "book"; }, index: number, array: { iconName: "bicycle" | "book"; }[]) => U, thisArg?: any) => U[] +>icon => [icon.iconName, 1] : (icon: { iconName: "bicycle" | "book"; }) => ["bicycle" | "book", number] +>icon : { iconName: "bicycle" | "book"; } +>[icon.iconName, 1] : ["bicycle" | "book", number] +>icon.iconName : "bicycle" | "book" +>icon : { iconName: "bicycle" | "book"; } +>iconName : "bicycle" | "book" +>1 : 1 + +}; + diff --git a/tsc/testdata/baselines/reference/compiler/partialDeepIntersectionCommonSupertype.js b/tsc/testdata/baselines/reference/compiler/partialDeepIntersectionCommonSupertype.js new file mode 100644 index 0000000000000..e893270895b3f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/partialDeepIntersectionCommonSupertype.js @@ -0,0 +1,16 @@ +//// [tests/cases/compiler/partialDeepIntersectionCommonSupertype.ts] //// + +//// [partialDeepIntersectionCommonSupertype.ts] +type PartialDeep = T extends object ? { [K in keyof T]?: PartialDeep } : T; +type Theme = T & { style: { message: (text: string) => string } }; +declare function makeTheme(...themes: PartialDeep>[]): Theme; +declare const theme: { style: { description: (text: string) => string } }; +declare const customization: PartialDeep>; +const merged = makeTheme(theme, customization); +merged.style.description(""); + + +//// [partialDeepIntersectionCommonSupertype.js] +"use strict"; +const merged = makeTheme(theme, customization); +merged.style.description(""); diff --git a/tsc/testdata/baselines/reference/compiler/partialDeepIntersectionCommonSupertype.symbols b/tsc/testdata/baselines/reference/compiler/partialDeepIntersectionCommonSupertype.symbols new file mode 100644 index 0000000000000..2deaff926d09c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/partialDeepIntersectionCommonSupertype.symbols @@ -0,0 +1,57 @@ +//// [tests/cases/compiler/partialDeepIntersectionCommonSupertype.ts] //// + +=== partialDeepIntersectionCommonSupertype.ts === +type PartialDeep = T extends object ? { [K in keyof T]?: PartialDeep } : T; +>PartialDeep : Symbol(PartialDeep, Decl(partialDeepIntersectionCommonSupertype.ts, 0, 0)) +>T : Symbol(T, Decl(partialDeepIntersectionCommonSupertype.ts, 0, 17)) +>T : Symbol(T, Decl(partialDeepIntersectionCommonSupertype.ts, 0, 17)) +>K : Symbol(K, Decl(partialDeepIntersectionCommonSupertype.ts, 0, 44)) +>T : Symbol(T, Decl(partialDeepIntersectionCommonSupertype.ts, 0, 17)) +>PartialDeep : Symbol(PartialDeep, Decl(partialDeepIntersectionCommonSupertype.ts, 0, 0)) +>T : Symbol(T, Decl(partialDeepIntersectionCommonSupertype.ts, 0, 17)) +>K : Symbol(K, Decl(partialDeepIntersectionCommonSupertype.ts, 0, 44)) +>T : Symbol(T, Decl(partialDeepIntersectionCommonSupertype.ts, 0, 17)) + +type Theme = T & { style: { message: (text: string) => string } }; +>Theme : Symbol(Theme, Decl(partialDeepIntersectionCommonSupertype.ts, 0, 84)) +>T : Symbol(T, Decl(partialDeepIntersectionCommonSupertype.ts, 1, 11)) +>T : Symbol(T, Decl(partialDeepIntersectionCommonSupertype.ts, 1, 11)) +>style : Symbol(style, Decl(partialDeepIntersectionCommonSupertype.ts, 1, 36)) +>message : Symbol(message, Decl(partialDeepIntersectionCommonSupertype.ts, 1, 45)) +>text : Symbol(text, Decl(partialDeepIntersectionCommonSupertype.ts, 1, 56)) + +declare function makeTheme(...themes: PartialDeep>[]): Theme; +>makeTheme : Symbol(makeTheme, Decl(partialDeepIntersectionCommonSupertype.ts, 1, 84)) +>T : Symbol(T, Decl(partialDeepIntersectionCommonSupertype.ts, 2, 27)) +>themes : Symbol(themes, Decl(partialDeepIntersectionCommonSupertype.ts, 2, 45)) +>PartialDeep : Symbol(PartialDeep, Decl(partialDeepIntersectionCommonSupertype.ts, 0, 0)) +>Theme : Symbol(Theme, Decl(partialDeepIntersectionCommonSupertype.ts, 0, 84)) +>T : Symbol(T, Decl(partialDeepIntersectionCommonSupertype.ts, 2, 27)) +>Theme : Symbol(Theme, Decl(partialDeepIntersectionCommonSupertype.ts, 0, 84)) +>T : Symbol(T, Decl(partialDeepIntersectionCommonSupertype.ts, 2, 27)) + +declare const theme: { style: { description: (text: string) => string } }; +>theme : Symbol(theme, Decl(partialDeepIntersectionCommonSupertype.ts, 3, 13)) +>style : Symbol(style, Decl(partialDeepIntersectionCommonSupertype.ts, 3, 22)) +>description : Symbol(description, Decl(partialDeepIntersectionCommonSupertype.ts, 3, 31)) +>text : Symbol(text, Decl(partialDeepIntersectionCommonSupertype.ts, 3, 46)) + +declare const customization: PartialDeep>; +>customization : Symbol(customization, Decl(partialDeepIntersectionCommonSupertype.ts, 4, 13)) +>PartialDeep : Symbol(PartialDeep, Decl(partialDeepIntersectionCommonSupertype.ts, 0, 0)) +>Theme : Symbol(Theme, Decl(partialDeepIntersectionCommonSupertype.ts, 0, 84)) +>theme : Symbol(theme, Decl(partialDeepIntersectionCommonSupertype.ts, 3, 13)) + +const merged = makeTheme(theme, customization); +>merged : Symbol(merged, Decl(partialDeepIntersectionCommonSupertype.ts, 5, 5)) +>makeTheme : Symbol(makeTheme, Decl(partialDeepIntersectionCommonSupertype.ts, 1, 84)) +>theme : Symbol(theme, Decl(partialDeepIntersectionCommonSupertype.ts, 3, 13)) +>customization : Symbol(customization, Decl(partialDeepIntersectionCommonSupertype.ts, 4, 13)) + +merged.style.description(""); +>merged.style.description : Symbol(description, Decl(partialDeepIntersectionCommonSupertype.ts, 3, 31)) +>merged.style : Symbol(style, Decl(partialDeepIntersectionCommonSupertype.ts, 3, 22), Decl(partialDeepIntersectionCommonSupertype.ts, 1, 36)) +>merged : Symbol(merged, Decl(partialDeepIntersectionCommonSupertype.ts, 5, 5)) +>style : Symbol(style, Decl(partialDeepIntersectionCommonSupertype.ts, 3, 22), Decl(partialDeepIntersectionCommonSupertype.ts, 1, 36)) +>description : Symbol(description, Decl(partialDeepIntersectionCommonSupertype.ts, 3, 31)) + diff --git a/tsc/testdata/baselines/reference/compiler/partialDeepIntersectionCommonSupertype.types b/tsc/testdata/baselines/reference/compiler/partialDeepIntersectionCommonSupertype.types new file mode 100644 index 0000000000000..4e516fcb682f1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/partialDeepIntersectionCommonSupertype.types @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/partialDeepIntersectionCommonSupertype.ts] //// + +=== partialDeepIntersectionCommonSupertype.ts === +type PartialDeep = T extends object ? { [K in keyof T]?: PartialDeep } : T; +>PartialDeep : PartialDeep + +type Theme = T & { style: { message: (text: string) => string } }; +>Theme : Theme +>style : { message: (text: string) => string; } +>message : (text: string) => string +>text : string + +declare function makeTheme(...themes: PartialDeep>[]): Theme; +>makeTheme : (...themes: PartialDeep>[]) => Theme +>themes : PartialDeep>[] + +declare const theme: { style: { description: (text: string) => string } }; +>theme : { style: { description: (text: string) => string; }; } +>style : { description: (text: string) => string; } +>description : (text: string) => string +>text : string + +declare const customization: PartialDeep>; +>customization : { style?: { message?: {} | undefined; description?: {} | undefined; } | undefined; } +>theme : { style: { description: (text: string) => string; }; } + +const merged = makeTheme(theme, customization); +>merged : Theme<{ style: { description: (text: string) => string; }; }> +>makeTheme(theme, customization) : Theme<{ style: { description: (text: string) => string; }; }> +>makeTheme : (...themes: PartialDeep>[]) => Theme +>theme : { style: { description: (text: string) => string; }; } +>customization : { style?: { message?: {} | undefined; description?: {} | undefined; } | undefined; } + +merged.style.description(""); +>merged.style.description("") : string +>merged.style.description : (text: string) => string +>merged.style : { description: (text: string) => string; } & { message: (text: string) => string; } +>merged : Theme<{ style: { description: (text: string) => string; }; }> +>style : { description: (text: string) => string; } & { message: (text: string) => string; } +>description : (text: string) => string +>"" : "" + diff --git a/tsc/testdata/baselines/reference/compiler/promiseAllArrayAssertionOverlap.js b/tsc/testdata/baselines/reference/compiler/promiseAllArrayAssertionOverlap.js new file mode 100644 index 0000000000000..1d7ea073d2f52 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/promiseAllArrayAssertionOverlap.js @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/promiseAllArrayAssertionOverlap.ts] //// + +//// [promiseAllArrayAssertionOverlap.ts] +interface Row { + [name: string]: any; +} +interface Entity { + id: number; +} +declare const result: Promise; + +export async function load() { + return (await Promise.all([result, result])) as Entity[]; +} + + +//// [promiseAllArrayAssertionOverlap.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +export function load() { + return __awaiter(this, void 0, void 0, function* () { + return (yield Promise.all([result, result])); + }); +} diff --git a/tsc/testdata/baselines/reference/compiler/promiseAllArrayAssertionOverlap.symbols b/tsc/testdata/baselines/reference/compiler/promiseAllArrayAssertionOverlap.symbols new file mode 100644 index 0000000000000..64182bbd096f4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/promiseAllArrayAssertionOverlap.symbols @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/promiseAllArrayAssertionOverlap.ts] //// + +=== promiseAllArrayAssertionOverlap.ts === +interface Row { +>Row : Symbol(Row, Decl(promiseAllArrayAssertionOverlap.ts, 0, 0)) + + [name: string]: any; +>name : Symbol(name, Decl(promiseAllArrayAssertionOverlap.ts, 1, 5)) +} +interface Entity { +>Entity : Symbol(Entity, Decl(promiseAllArrayAssertionOverlap.ts, 2, 1)) + + id: number; +>id : Symbol(Entity.id, Decl(promiseAllArrayAssertionOverlap.ts, 3, 18)) +} +declare const result: Promise; +>result : Symbol(result, Decl(promiseAllArrayAssertionOverlap.ts, 6, 13)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>Row : Symbol(Row, Decl(promiseAllArrayAssertionOverlap.ts, 0, 0)) + +export async function load() { +>load : Symbol(load, Decl(promiseAllArrayAssertionOverlap.ts, 6, 42)) + + return (await Promise.all([result, result])) as Entity[]; +>Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>all : Symbol(PromiseConstructor.all, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>result : Symbol(result, Decl(promiseAllArrayAssertionOverlap.ts, 6, 13)) +>result : Symbol(result, Decl(promiseAllArrayAssertionOverlap.ts, 6, 13)) +>Entity : Symbol(Entity, Decl(promiseAllArrayAssertionOverlap.ts, 2, 1)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/promiseAllArrayAssertionOverlap.types b/tsc/testdata/baselines/reference/compiler/promiseAllArrayAssertionOverlap.types new file mode 100644 index 0000000000000..d8ab523af8ceb --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/promiseAllArrayAssertionOverlap.types @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/promiseAllArrayAssertionOverlap.ts] //// + +=== promiseAllArrayAssertionOverlap.ts === +interface Row { + [name: string]: any; +>name : string +} +interface Entity { + id: number; +>id : number +} +declare const result: Promise; +>result : Promise + +export async function load() { +>load : () => Promise + + return (await Promise.all([result, result])) as Entity[]; +>(await Promise.all([result, result])) as Entity[] : Entity[] +>(await Promise.all([result, result])) : (Row | null)[] +>await Promise.all([result, result]) : (Row | null)[] +>Promise.all([result, result]) : Promise<(Row | null)[]> +>Promise.all : { (values: Iterable>): Promise[]>; (values: T): Promise<{ -readonly [P in keyof T]: Awaited; }>; } +>Promise : PromiseConstructor +>all : { (values: Iterable>): Promise[]>; (values: T): Promise<{ -readonly [P in keyof T]: Awaited; }>; } +>[result, result] : Promise[] +>result : Promise +>result : Promise +} + diff --git a/tsc/testdata/baselines/reference/compiler/promiseUnionCallbackStateInference.js b/tsc/testdata/baselines/reference/compiler/promiseUnionCallbackStateInference.js new file mode 100644 index 0000000000000..2264c71981f61 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/promiseUnionCallbackStateInference.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/promiseUnionCallbackStateInference.ts] //// + +//// [promiseUnionCallbackStateInference.ts] +declare function createAction( + action: (state: State) => State | Promise, + initialState: State, +): () => void; +declare function createAction( + action: (state: State, payload: string) => State | Promise, + initialState: State, +): (payload: string) => void; + +declare const action: (previous: unknown, value: string) => Promise; +const dispatch = createAction(action, null); +const bound = dispatch.bind(null, "value"); + + +//// [promiseUnionCallbackStateInference.js] +"use strict"; +const dispatch = createAction(action, null); +const bound = dispatch.bind(null, "value"); diff --git a/tsc/testdata/baselines/reference/compiler/promiseUnionCallbackStateInference.symbols b/tsc/testdata/baselines/reference/compiler/promiseUnionCallbackStateInference.symbols new file mode 100644 index 0000000000000..acb7064e5172a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/promiseUnionCallbackStateInference.symbols @@ -0,0 +1,57 @@ +//// [tests/cases/compiler/promiseUnionCallbackStateInference.ts] //// + +=== promiseUnionCallbackStateInference.ts === +declare function createAction( +>createAction : Symbol(createAction, Decl(promiseUnionCallbackStateInference.ts, 0, 0), Decl(promiseUnionCallbackStateInference.ts, 3, 14)) +>State : Symbol(State, Decl(promiseUnionCallbackStateInference.ts, 0, 30)) + + action: (state: State) => State | Promise, +>action : Symbol(action, Decl(promiseUnionCallbackStateInference.ts, 0, 37)) +>state : Symbol(state, Decl(promiseUnionCallbackStateInference.ts, 1, 13)) +>State : Symbol(State, Decl(promiseUnionCallbackStateInference.ts, 0, 30)) +>State : Symbol(State, Decl(promiseUnionCallbackStateInference.ts, 0, 30)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>State : Symbol(State, Decl(promiseUnionCallbackStateInference.ts, 0, 30)) + + initialState: State, +>initialState : Symbol(initialState, Decl(promiseUnionCallbackStateInference.ts, 1, 53)) +>State : Symbol(State, Decl(promiseUnionCallbackStateInference.ts, 0, 30)) + +): () => void; +declare function createAction( +>createAction : Symbol(createAction, Decl(promiseUnionCallbackStateInference.ts, 0, 0), Decl(promiseUnionCallbackStateInference.ts, 3, 14)) +>State : Symbol(State, Decl(promiseUnionCallbackStateInference.ts, 4, 30)) + + action: (state: State, payload: string) => State | Promise, +>action : Symbol(action, Decl(promiseUnionCallbackStateInference.ts, 4, 37)) +>state : Symbol(state, Decl(promiseUnionCallbackStateInference.ts, 5, 13)) +>State : Symbol(State, Decl(promiseUnionCallbackStateInference.ts, 4, 30)) +>payload : Symbol(payload, Decl(promiseUnionCallbackStateInference.ts, 5, 26)) +>State : Symbol(State, Decl(promiseUnionCallbackStateInference.ts, 4, 30)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>State : Symbol(State, Decl(promiseUnionCallbackStateInference.ts, 4, 30)) + + initialState: State, +>initialState : Symbol(initialState, Decl(promiseUnionCallbackStateInference.ts, 5, 70)) +>State : Symbol(State, Decl(promiseUnionCallbackStateInference.ts, 4, 30)) + +): (payload: string) => void; +>payload : Symbol(payload, Decl(promiseUnionCallbackStateInference.ts, 7, 4)) + +declare const action: (previous: unknown, value: string) => Promise; +>action : Symbol(action, Decl(promiseUnionCallbackStateInference.ts, 9, 13)) +>previous : Symbol(previous, Decl(promiseUnionCallbackStateInference.ts, 9, 23)) +>value : Symbol(value, Decl(promiseUnionCallbackStateInference.ts, 9, 41)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + +const dispatch = createAction(action, null); +>dispatch : Symbol(dispatch, Decl(promiseUnionCallbackStateInference.ts, 10, 5)) +>createAction : Symbol(createAction, Decl(promiseUnionCallbackStateInference.ts, 0, 0), Decl(promiseUnionCallbackStateInference.ts, 3, 14)) +>action : Symbol(action, Decl(promiseUnionCallbackStateInference.ts, 9, 13)) + +const bound = dispatch.bind(null, "value"); +>bound : Symbol(bound, Decl(promiseUnionCallbackStateInference.ts, 11, 5)) +>dispatch.bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>dispatch : Symbol(dispatch, Decl(promiseUnionCallbackStateInference.ts, 10, 5)) +>bind : Symbol(CallableFunction.bind, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + diff --git a/tsc/testdata/baselines/reference/compiler/promiseUnionCallbackStateInference.types b/tsc/testdata/baselines/reference/compiler/promiseUnionCallbackStateInference.types new file mode 100644 index 0000000000000..dbe55252f676d --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/promiseUnionCallbackStateInference.types @@ -0,0 +1,47 @@ +//// [tests/cases/compiler/promiseUnionCallbackStateInference.ts] //// + +=== promiseUnionCallbackStateInference.ts === +declare function createAction( +>createAction : { (action: (state: State) => State | Promise, initialState: State): () => void; (action: (state: State_1, payload: string) => State_1 | Promise, initialState: State_1): (payload: string) => void; } + + action: (state: State) => State | Promise, +>action : (state: State) => State | Promise +>state : State + + initialState: State, +>initialState : State + +): () => void; +declare function createAction( +>createAction : { (action: (state: State_1) => State_1 | Promise, initialState: State_1): () => void; (action: (state: State, payload: string) => State | Promise, initialState: State): (payload: string) => void; } + + action: (state: State, payload: string) => State | Promise, +>action : (state: State, payload: string) => State | Promise +>state : State +>payload : string + + initialState: State, +>initialState : State + +): (payload: string) => void; +>payload : string + +declare const action: (previous: unknown, value: string) => Promise; +>action : (previous: unknown, value: string) => Promise +>previous : unknown +>value : string + +const dispatch = createAction(action, null); +>dispatch : (payload: string) => void +>createAction(action, null) : (payload: string) => void +>createAction : { (action: (state: State) => State | Promise, initialState: State): () => void; (action: (state: State, payload: string) => State | Promise, initialState: State): (payload: string) => void; } +>action : (previous: unknown, value: string) => Promise + +const bound = dispatch.bind(null, "value"); +>bound : () => void +>dispatch.bind(null, "value") : () => void +>dispatch.bind : { (this: T, thisArg: ThisParameterType): OmitThisParameter; (this: (this: T, ...args: [...A, ...B]) => R, thisArg: T, ...args: A): (...args: B) => R; } +>dispatch : (payload: string) => void +>bind : { (this: T, thisArg: ThisParameterType): OmitThisParameter; (this: (this: T, ...args: [...A, ...B]) => R, thisArg: T, ...args: A): (...args: B) => R; } +>"value" : "value" + diff --git a/tsc/testdata/baselines/reference/compiler/redundantNumericLiteralComparison.js b/tsc/testdata/baselines/reference/compiler/redundantNumericLiteralComparison.js new file mode 100644 index 0000000000000..f6b1af1ae9d45 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/redundantNumericLiteralComparison.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/redundantNumericLiteralComparison.ts] //// + +//// [redundantNumericLiteralComparison.ts] +function shouldRetry(retryCount: number, currentCount: number) { + return retryCount === -1 || (retryCount !== -1 && currentCount <= retryCount); +} + + +//// [redundantNumericLiteralComparison.js] +"use strict"; +function shouldRetry(retryCount, currentCount) { + return retryCount === -1 || (retryCount !== -1 && currentCount <= retryCount); +} diff --git a/tsc/testdata/baselines/reference/compiler/redundantNumericLiteralComparison.symbols b/tsc/testdata/baselines/reference/compiler/redundantNumericLiteralComparison.symbols new file mode 100644 index 0000000000000..87036e32f0fd4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/redundantNumericLiteralComparison.symbols @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/redundantNumericLiteralComparison.ts] //// + +=== redundantNumericLiteralComparison.ts === +function shouldRetry(retryCount: number, currentCount: number) { +>shouldRetry : Symbol(shouldRetry, Decl(redundantNumericLiteralComparison.ts, 0, 0)) +>retryCount : Symbol(retryCount, Decl(redundantNumericLiteralComparison.ts, 0, 21)) +>currentCount : Symbol(currentCount, Decl(redundantNumericLiteralComparison.ts, 0, 40)) + + return retryCount === -1 || (retryCount !== -1 && currentCount <= retryCount); +>retryCount : Symbol(retryCount, Decl(redundantNumericLiteralComparison.ts, 0, 21)) +>retryCount : Symbol(retryCount, Decl(redundantNumericLiteralComparison.ts, 0, 21)) +>currentCount : Symbol(currentCount, Decl(redundantNumericLiteralComparison.ts, 0, 40)) +>retryCount : Symbol(retryCount, Decl(redundantNumericLiteralComparison.ts, 0, 21)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/redundantNumericLiteralComparison.types b/tsc/testdata/baselines/reference/compiler/redundantNumericLiteralComparison.types new file mode 100644 index 0000000000000..ca69d96fc529a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/redundantNumericLiteralComparison.types @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/redundantNumericLiteralComparison.ts] //// + +=== redundantNumericLiteralComparison.ts === +function shouldRetry(retryCount: number, currentCount: number) { +>shouldRetry : (retryCount: number, currentCount: number) => boolean +>retryCount : number +>currentCount : number + + return retryCount === -1 || (retryCount !== -1 && currentCount <= retryCount); +>retryCount === -1 || (retryCount !== -1 && currentCount <= retryCount) : boolean +>retryCount === -1 : boolean +>retryCount : number +>-1 : -1 +>1 : 1 +>(retryCount !== -1 && currentCount <= retryCount) : boolean +>retryCount !== -1 && currentCount <= retryCount : boolean +>retryCount !== -1 : boolean +>retryCount : number +>-1 : -1 +>1 : 1 +>currentCount <= retryCount : boolean +>currentCount : number +>retryCount : number +} + diff --git a/tsc/testdata/baselines/reference/compiler/regexpConstructorMatchGroups.js b/tsc/testdata/baselines/reference/compiler/regexpConstructorMatchGroups.js new file mode 100644 index 0000000000000..e7329ff7929ce --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/regexpConstructorMatchGroups.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/regexpConstructorMatchGroups.ts] //// + +//// [regexpConstructorMatchGroups.ts] +declare const pattern: string; +const matches = "".match(new RegExp(pattern)); +if (matches) matches.groups; + + +//// [regexpConstructorMatchGroups.js] +"use strict"; +const matches = "".match(new RegExp(pattern)); +if (matches) + matches.groups; diff --git a/tsc/testdata/baselines/reference/compiler/regexpConstructorMatchGroups.symbols b/tsc/testdata/baselines/reference/compiler/regexpConstructorMatchGroups.symbols new file mode 100644 index 0000000000000..79c02453734ed --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/regexpConstructorMatchGroups.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/regexpConstructorMatchGroups.ts] //// + +=== regexpConstructorMatchGroups.ts === +declare const pattern: string; +>pattern : Symbol(pattern, Decl(regexpConstructorMatchGroups.ts, 0, 13)) + +const matches = "".match(new RegExp(pattern)); +>matches : Symbol(matches, Decl(regexpConstructorMatchGroups.ts, 1, 5)) +>"".match : Symbol(String.match, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>match : Symbol(String.match, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.regexp.d.ts, --, --)) +>pattern : Symbol(pattern, Decl(regexpConstructorMatchGroups.ts, 0, 13)) + +if (matches) matches.groups; +>matches : Symbol(matches, Decl(regexpConstructorMatchGroups.ts, 1, 5)) +>matches.groups : Symbol(RegExpMatchArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) +>matches : Symbol(matches, Decl(regexpConstructorMatchGroups.ts, 1, 5)) +>groups : Symbol(RegExpMatchArray.groups, Decl(lib.es2018.regexp.d.ts, --, --)) + diff --git a/tsc/testdata/baselines/reference/compiler/regexpConstructorMatchGroups.types b/tsc/testdata/baselines/reference/compiler/regexpConstructorMatchGroups.types new file mode 100644 index 0000000000000..ec6dfa71a2bbf --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/regexpConstructorMatchGroups.types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/regexpConstructorMatchGroups.ts] //// + +=== regexpConstructorMatchGroups.ts === +declare const pattern: string; +>pattern : string + +const matches = "".match(new RegExp(pattern)); +>matches : RegExpMatchArray | null +>"".match(new RegExp(pattern)) : RegExpMatchArray | null +>"".match : { (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; } +>"" : "" +>match : { (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; } +>new RegExp(pattern) : RegExp +>RegExp : RegExpConstructor +>pattern : string + +if (matches) matches.groups; +>matches : RegExpMatchArray | null +>matches.groups : { [key: string]: string; } | undefined +>matches : RegExpMatchArray +>groups : { [key: string]: string; } | undefined + diff --git a/tsc/testdata/baselines/reference/compiler/regexpGlobalConstructorMatchIteration.js b/tsc/testdata/baselines/reference/compiler/regexpGlobalConstructorMatchIteration.js new file mode 100644 index 0000000000000..fe0eeee29075a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/regexpGlobalConstructorMatchIteration.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/regexpGlobalConstructorMatchIteration.ts] //// + +//// [regexpGlobalConstructorMatchIteration.ts] +declare const pattern: string; +declare function consume(value: string): void; +const matches = "".match(new RegExp(pattern, "g")); +if (matches) { + for (const match of matches) { + consume(match); + } +} + + +//// [regexpGlobalConstructorMatchIteration.js] +"use strict"; +const matches = "".match(new RegExp(pattern, "g")); +if (matches) { + for (const match of matches) { + consume(match); + } +} diff --git a/tsc/testdata/baselines/reference/compiler/regexpGlobalConstructorMatchIteration.symbols b/tsc/testdata/baselines/reference/compiler/regexpGlobalConstructorMatchIteration.symbols new file mode 100644 index 0000000000000..5c8d472f6656b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/regexpGlobalConstructorMatchIteration.symbols @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/regexpGlobalConstructorMatchIteration.ts] //// + +=== regexpGlobalConstructorMatchIteration.ts === +declare const pattern: string; +>pattern : Symbol(pattern, Decl(regexpGlobalConstructorMatchIteration.ts, 0, 13)) + +declare function consume(value: string): void; +>consume : Symbol(consume, Decl(regexpGlobalConstructorMatchIteration.ts, 0, 30)) +>value : Symbol(value, Decl(regexpGlobalConstructorMatchIteration.ts, 1, 25)) + +const matches = "".match(new RegExp(pattern, "g")); +>matches : Symbol(matches, Decl(regexpGlobalConstructorMatchIteration.ts, 2, 5)) +>"".match : Symbol(String.match, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>match : Symbol(String.match, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>pattern : Symbol(pattern, Decl(regexpGlobalConstructorMatchIteration.ts, 0, 13)) + +if (matches) { +>matches : Symbol(matches, Decl(regexpGlobalConstructorMatchIteration.ts, 2, 5)) + + for (const match of matches) { +>match : Symbol(match, Decl(regexpGlobalConstructorMatchIteration.ts, 4, 14)) +>matches : Symbol(matches, Decl(regexpGlobalConstructorMatchIteration.ts, 2, 5)) + + consume(match); +>consume : Symbol(consume, Decl(regexpGlobalConstructorMatchIteration.ts, 0, 30)) +>match : Symbol(match, Decl(regexpGlobalConstructorMatchIteration.ts, 4, 14)) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/regexpGlobalConstructorMatchIteration.types b/tsc/testdata/baselines/reference/compiler/regexpGlobalConstructorMatchIteration.types new file mode 100644 index 0000000000000..ff0892e2ecb34 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/regexpGlobalConstructorMatchIteration.types @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/regexpGlobalConstructorMatchIteration.ts] //// + +=== regexpGlobalConstructorMatchIteration.ts === +declare const pattern: string; +>pattern : string + +declare function consume(value: string): void; +>consume : (value: string) => void +>value : string + +const matches = "".match(new RegExp(pattern, "g")); +>matches : RegExpMatchArray | null +>"".match(new RegExp(pattern, "g")) : RegExpMatchArray | null +>"".match : { (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; } +>"" : "" +>match : { (regexp: string | RegExp): RegExpMatchArray | null; (matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; } +>new RegExp(pattern, "g") : RegExp +>RegExp : RegExpConstructor +>pattern : string +>"g" : "g" + +if (matches) { +>matches : RegExpMatchArray | null + + for (const match of matches) { +>match : string +>matches : RegExpMatchArray + + consume(match); +>consume(match) : void +>consume : (value: string) => void +>match : string + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/regexpOptionalCaptureStringArray.js b/tsc/testdata/baselines/reference/compiler/regexpOptionalCaptureStringArray.js new file mode 100644 index 0000000000000..0ad730ad2fdd5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/regexpOptionalCaptureStringArray.js @@ -0,0 +1,9 @@ +//// [tests/cases/compiler/regexpOptionalCaptureStringArray.ts] //// + +//// [regexpOptionalCaptureStringArray.ts] +const result: string[] | null = /^(a)?$/.exec(""); + + +//// [regexpOptionalCaptureStringArray.js] +"use strict"; +const result = /^(a)?$/.exec(""); diff --git a/tsc/testdata/baselines/reference/compiler/regexpOptionalCaptureStringArray.symbols b/tsc/testdata/baselines/reference/compiler/regexpOptionalCaptureStringArray.symbols new file mode 100644 index 0000000000000..9d6fe5c746e1e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/regexpOptionalCaptureStringArray.symbols @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/regexpOptionalCaptureStringArray.ts] //// + +=== regexpOptionalCaptureStringArray.ts === +const result: string[] | null = /^(a)?$/.exec(""); +>result : Symbol(result, Decl(regexpOptionalCaptureStringArray.ts, 0, 5)) +>/^(a)?$/.exec : Symbol(RegExp.exec, Decl(lib.es5.d.ts, --, --)) +>exec : Symbol(RegExp.exec, Decl(lib.es5.d.ts, --, --)) + diff --git a/tsc/testdata/baselines/reference/compiler/regexpOptionalCaptureStringArray.types b/tsc/testdata/baselines/reference/compiler/regexpOptionalCaptureStringArray.types new file mode 100644 index 0000000000000..652a64f384f4b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/regexpOptionalCaptureStringArray.types @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/regexpOptionalCaptureStringArray.ts] //// + +=== regexpOptionalCaptureStringArray.ts === +const result: string[] | null = /^(a)?$/.exec(""); +>result : string[] | null +>/^(a)?$/.exec("") : RegExpExecArray | null +>/^(a)?$/.exec : (string: string) => RegExpExecArray | null +>/^(a)?$/ : RegExp +>exec : (string: string) => RegExpExecArray | null +>"" : "" + diff --git a/tsc/testdata/baselines/reference/compiler/regexpReplaceSingleParameterCallback.js b/tsc/testdata/baselines/reference/compiler/regexpReplaceSingleParameterCallback.js new file mode 100644 index 0000000000000..74aae3a82c05e --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/regexpReplaceSingleParameterCallback.js @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/regexpReplaceSingleParameterCallback.ts] //// + +//// [regexpReplaceSingleParameterCallback.ts] +declare const pattern: RegExp; +declare const replace: (value: string) => string; +"".replace(pattern, replace); + + +//// [regexpReplaceSingleParameterCallback.js] +"use strict"; +"".replace(pattern, replace); diff --git a/tsc/testdata/baselines/reference/compiler/regexpReplaceSingleParameterCallback.symbols b/tsc/testdata/baselines/reference/compiler/regexpReplaceSingleParameterCallback.symbols new file mode 100644 index 0000000000000..1cf44d81cd117 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/regexpReplaceSingleParameterCallback.symbols @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/regexpReplaceSingleParameterCallback.ts] //// + +=== regexpReplaceSingleParameterCallback.ts === +declare const pattern: RegExp; +>pattern : Symbol(pattern, Decl(regexpReplaceSingleParameterCallback.ts, 0, 13)) +>RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + +declare const replace: (value: string) => string; +>replace : Symbol(replace, Decl(regexpReplaceSingleParameterCallback.ts, 1, 13)) +>value : Symbol(value, Decl(regexpReplaceSingleParameterCallback.ts, 1, 24)) + +"".replace(pattern, replace); +>"".replace : Symbol(String.replace, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>replace : Symbol(String.replace, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>pattern : Symbol(pattern, Decl(regexpReplaceSingleParameterCallback.ts, 0, 13)) +>replace : Symbol(replace, Decl(regexpReplaceSingleParameterCallback.ts, 1, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/regexpReplaceSingleParameterCallback.types b/tsc/testdata/baselines/reference/compiler/regexpReplaceSingleParameterCallback.types new file mode 100644 index 0000000000000..2d584052b5dba --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/regexpReplaceSingleParameterCallback.types @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/regexpReplaceSingleParameterCallback.ts] //// + +=== regexpReplaceSingleParameterCallback.ts === +declare const pattern: RegExp; +>pattern : RegExp + +declare const replace: (value: string) => string; +>replace : (value: string) => string +>value : string + +"".replace(pattern, replace); +>"".replace(pattern, replace) : string +>"".replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; (searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; } +>"" : "" +>replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; (searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; } +>pattern : RegExp +>replace : (value: string) => string + diff --git a/tsc/testdata/baselines/reference/compiler/regexpUnmatchedCaptureIndices.errors.txt b/tsc/testdata/baselines/reference/compiler/regexpUnmatchedCaptureIndices.errors.txt new file mode 100644 index 0000000000000..b91c316d0ea26 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/regexpUnmatchedCaptureIndices.errors.txt @@ -0,0 +1,21 @@ +regexpUnmatchedCaptureIndices.ts(3,5): error TS2532: Object is possibly 'undefined'. +regexpUnmatchedCaptureIndices.ts(4,5): error TS2532: Object is possibly 'undefined'. + + +==== regexpUnmatchedCaptureIndices.ts (2 errors) ==== + const match = /(section)?/d.exec(""); + if (match) { + match.indices![1][0]; + ~~~~~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + match.indices![1][1]; + ~~~~~~~~~~~~~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + + const indices = match.indices![1]; + if (indices) { + indices[0]; + indices[1]; + } + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/regexpUnmatchedCaptureIndices.symbols b/tsc/testdata/baselines/reference/compiler/regexpUnmatchedCaptureIndices.symbols new file mode 100644 index 0000000000000..07ccf5c27a116 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/regexpUnmatchedCaptureIndices.symbols @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/regexpUnmatchedCaptureIndices.ts] //// + +=== regexpUnmatchedCaptureIndices.ts === +const match = /(section)?/d.exec(""); +>match : Symbol(match, Decl(regexpUnmatchedCaptureIndices.ts, 0, 5)) +>/(section)?/d.exec : Symbol(RegExp.exec, Decl(lib.es5.d.ts, --, --)) +>exec : Symbol(RegExp.exec, Decl(lib.es5.d.ts, --, --)) + +if (match) { +>match : Symbol(match, Decl(regexpUnmatchedCaptureIndices.ts, 0, 5)) + + match.indices![1][0]; +>match.indices : Symbol(RegExpExecArray.indices, Decl(lib.es2022.regexp.d.ts, --, --)) +>match : Symbol(match, Decl(regexpUnmatchedCaptureIndices.ts, 0, 5)) +>indices : Symbol(RegExpExecArray.indices, Decl(lib.es2022.regexp.d.ts, --, --)) + + match.indices![1][1]; +>match.indices : Symbol(RegExpExecArray.indices, Decl(lib.es2022.regexp.d.ts, --, --)) +>match : Symbol(match, Decl(regexpUnmatchedCaptureIndices.ts, 0, 5)) +>indices : Symbol(RegExpExecArray.indices, Decl(lib.es2022.regexp.d.ts, --, --)) + + const indices = match.indices![1]; +>indices : Symbol(indices, Decl(regexpUnmatchedCaptureIndices.ts, 5, 9)) +>match.indices : Symbol(RegExpExecArray.indices, Decl(lib.es2022.regexp.d.ts, --, --)) +>match : Symbol(match, Decl(regexpUnmatchedCaptureIndices.ts, 0, 5)) +>indices : Symbol(RegExpExecArray.indices, Decl(lib.es2022.regexp.d.ts, --, --)) + + if (indices) { +>indices : Symbol(indices, Decl(regexpUnmatchedCaptureIndices.ts, 5, 9)) + + indices[0]; +>indices : Symbol(indices, Decl(regexpUnmatchedCaptureIndices.ts, 5, 9)) +>0 : Symbol(0) + + indices[1]; +>indices : Symbol(indices, Decl(regexpUnmatchedCaptureIndices.ts, 5, 9)) +>1 : Symbol(1) + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/regexpUnmatchedCaptureIndices.types b/tsc/testdata/baselines/reference/compiler/regexpUnmatchedCaptureIndices.types new file mode 100644 index 0000000000000..d5926ef2c568b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/regexpUnmatchedCaptureIndices.types @@ -0,0 +1,58 @@ +//// [tests/cases/compiler/regexpUnmatchedCaptureIndices.ts] //// + +=== regexpUnmatchedCaptureIndices.ts === +const match = /(section)?/d.exec(""); +>match : RegExpExecArray | null +>/(section)?/d.exec("") : RegExpExecArray | null +>/(section)?/d.exec : (string: string) => RegExpExecArray | null +>/(section)?/d : RegExp +>exec : (string: string) => RegExpExecArray | null +>"" : "" + +if (match) { +>match : RegExpExecArray | null + + match.indices![1][0]; +>match.indices![1][0] : number +>match.indices![1] : [number, number] | undefined +>match.indices! : RegExpIndicesArray +>match.indices : RegExpIndicesArray | undefined +>match : RegExpExecArray +>indices : RegExpIndicesArray | undefined +>1 : 1 +>0 : 0 + + match.indices![1][1]; +>match.indices![1][1] : number +>match.indices![1] : [number, number] | undefined +>match.indices! : RegExpIndicesArray +>match.indices : RegExpIndicesArray | undefined +>match : RegExpExecArray +>indices : RegExpIndicesArray | undefined +>1 : 1 +>1 : 1 + + const indices = match.indices![1]; +>indices : [number, number] | undefined +>match.indices![1] : [number, number] | undefined +>match.indices! : RegExpIndicesArray +>match.indices : RegExpIndicesArray | undefined +>match : RegExpExecArray +>indices : RegExpIndicesArray | undefined +>1 : 1 + + if (indices) { +>indices : [number, number] | undefined + + indices[0]; +>indices[0] : number +>indices : [number, number] +>0 : 0 + + indices[1]; +>indices[1] : number +>indices : [number, number] +>1 : 1 + } +} + diff --git a/tsc/testdata/baselines/reference/compiler/routeComponentMetadata.symbols b/tsc/testdata/baselines/reference/compiler/routeComponentMetadata.symbols new file mode 100644 index 0000000000000..b0837e66304fc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/routeComponentMetadata.symbols @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/routeComponentMetadata.ts] //// + +=== routeComponentMetadata.ts === +type Component = (() => number) | ((() => number) & { readonly $$typeof: symbol }); +>Component : Symbol(Component, Decl(routeComponentMetadata.ts, 0, 0)) +>$$typeof : Symbol($$typeof, Decl(routeComponentMetadata.ts, 0, 53)) + +type RouteComponent = Component & { preload?: () => Promise }; +>RouteComponent : Symbol(RouteComponent, Decl(routeComponentMetadata.ts, 0, 83)) +>Component : Symbol(Component, Decl(routeComponentMetadata.ts, 0, 0)) +>preload : Symbol(preload, Decl(routeComponentMetadata.ts, 1, 35)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) + +declare function createRoute(options: { component?: RouteComponent; validateSearch?: (search: unknown) => Search }): { useSearch(): Search }; +>createRoute : Symbol(createRoute, Decl(routeComponentMetadata.ts, 1, 68)) +>Search : Symbol(Search, Decl(routeComponentMetadata.ts, 2, 29)) +>options : Symbol(options, Decl(routeComponentMetadata.ts, 2, 42)) +>component : Symbol(component, Decl(routeComponentMetadata.ts, 2, 52)) +>RouteComponent : Symbol(RouteComponent, Decl(routeComponentMetadata.ts, 0, 83)) +>validateSearch : Symbol(validateSearch, Decl(routeComponentMetadata.ts, 2, 80)) +>search : Symbol(search, Decl(routeComponentMetadata.ts, 2, 99)) +>Search : Symbol(Search, Decl(routeComponentMetadata.ts, 2, 29)) +>useSearch : Symbol(useSearch, Decl(routeComponentMetadata.ts, 2, 131)) +>Search : Symbol(Search, Decl(routeComponentMetadata.ts, 2, 29)) + +declare const schema: { parse(search: unknown): { page: number } }; +>schema : Symbol(schema, Decl(routeComponentMetadata.ts, 3, 13)) +>parse : Symbol(parse, Decl(routeComponentMetadata.ts, 3, 23)) +>search : Symbol(search, Decl(routeComponentMetadata.ts, 3, 30)) +>page : Symbol(page, Decl(routeComponentMetadata.ts, 3, 49)) + +const route = createRoute({ component: () => 0, validateSearch: search => schema.parse(search) }); +>route : Symbol(route, Decl(routeComponentMetadata.ts, 4, 5)) +>createRoute : Symbol(createRoute, Decl(routeComponentMetadata.ts, 1, 68)) +>component : Symbol(component, Decl(routeComponentMetadata.ts, 4, 27)) +>validateSearch : Symbol(validateSearch, Decl(routeComponentMetadata.ts, 4, 47)) +>search : Symbol(search, Decl(routeComponentMetadata.ts, 4, 63)) +>schema.parse : Symbol(parse, Decl(routeComponentMetadata.ts, 3, 23)) +>schema : Symbol(schema, Decl(routeComponentMetadata.ts, 3, 13)) +>parse : Symbol(parse, Decl(routeComponentMetadata.ts, 3, 23)) +>search : Symbol(search, Decl(routeComponentMetadata.ts, 4, 63)) + +route.useSearch().page; +>route.useSearch().page : Symbol(page, Decl(routeComponentMetadata.ts, 3, 49)) +>route.useSearch : Symbol(useSearch, Decl(routeComponentMetadata.ts, 2, 131)) +>route : Symbol(route, Decl(routeComponentMetadata.ts, 4, 5)) +>useSearch : Symbol(useSearch, Decl(routeComponentMetadata.ts, 2, 131)) +>page : Symbol(page, Decl(routeComponentMetadata.ts, 3, 49)) + diff --git a/tsc/testdata/baselines/reference/compiler/routeComponentMetadata.types b/tsc/testdata/baselines/reference/compiler/routeComponentMetadata.types new file mode 100644 index 0000000000000..a5ae679a140c2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/routeComponentMetadata.types @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/routeComponentMetadata.ts] //// + +=== routeComponentMetadata.ts === +type Component = (() => number) | ((() => number) & { readonly $$typeof: symbol }); +>Component : Component +>$$typeof : symbol + +type RouteComponent = Component & { preload?: () => Promise }; +>RouteComponent : RouteComponent +>preload : (() => Promise) | undefined + +declare function createRoute(options: { component?: RouteComponent; validateSearch?: (search: unknown) => Search }): { useSearch(): Search }; +>createRoute : (options: { component?: RouteComponent; validateSearch?: (search: unknown) => Search; }) => { useSearch(): Search; } +>options : { component?: RouteComponent; validateSearch?: (search: unknown) => Search; } +>component : RouteComponent | undefined +>validateSearch : ((search: unknown) => Search) | undefined +>search : unknown +>useSearch : () => Search + +declare const schema: { parse(search: unknown): { page: number } }; +>schema : { parse(search: unknown): { page: number; }; } +>parse : (search: unknown) => { page: number; } +>search : unknown +>page : number + +const route = createRoute({ component: () => 0, validateSearch: search => schema.parse(search) }); +>route : { useSearch(): { page: number; }; } +>createRoute({ component: () => 0, validateSearch: search => schema.parse(search) }) : { useSearch(): { page: number; }; } +>createRoute : (options: { component?: RouteComponent; validateSearch?: (search: unknown) => Search; }) => { useSearch(): Search; } +>{ component: () => 0, validateSearch: search => schema.parse(search) } : { component: () => number; validateSearch: (search: unknown) => { page: number; }; } +>component : () => number +>() => 0 : () => number +>0 : 0 +>validateSearch : (search: unknown) => { page: number; } +>search => schema.parse(search) : (search: unknown) => { page: number; } +>search : unknown +>schema.parse(search) : { page: number; } +>schema.parse : (search: unknown) => { page: number; } +>schema : { parse(search: unknown): { page: number; }; } +>parse : (search: unknown) => { page: number; } +>search : unknown + +route.useSearch().page; +>route.useSearch().page : number +>route.useSearch() : { page: number; } +>route.useSearch : () => { page: number; } +>route : { useSearch(): { page: number; }; } +>useSearch : () => { page: number; } +>page : number + diff --git a/tsc/testdata/baselines/reference/compiler/schemaCallableReturnMetadata.symbols b/tsc/testdata/baselines/reference/compiler/schemaCallableReturnMetadata.symbols new file mode 100644 index 0000000000000..d9fc2340c6de1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/schemaCallableReturnMetadata.symbols @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/schemaCallableReturnMetadata.ts] //// + +=== schemaCallableReturnMetadata.ts === +type Test = (() => void) & { options?: {} }; +>Test : Symbol(Test, Decl(schemaCallableReturnMetadata.ts, 0, 0)) +>options : Symbol(options, Decl(schemaCallableReturnMetadata.ts, 0, 28)) + +interface ISchema { +>ISchema : Symbol(ISchema, Decl(schemaCallableReturnMetadata.ts, 0, 44)) + + resolve(): ISchema; +>resolve : Symbol(ISchema.resolve, Decl(schemaCallableReturnMetadata.ts, 1, 19)) +>ISchema : Symbol(ISchema, Decl(schemaCallableReturnMetadata.ts, 0, 44)) + + asNestedTest(): Test; +>asNestedTest : Symbol(ISchema.asNestedTest, Decl(schemaCallableReturnMetadata.ts, 2, 23)) +>Test : Symbol(Test, Decl(schemaCallableReturnMetadata.ts, 0, 0)) +} + +class Schema implements ISchema { +>Schema : Symbol(Schema, Decl(schemaCallableReturnMetadata.ts, 4, 1)) +>ISchema : Symbol(ISchema, Decl(schemaCallableReturnMetadata.ts, 0, 44)) + + resolve() { return this; } +>resolve : Symbol(Schema.resolve, Decl(schemaCallableReturnMetadata.ts, 6, 33)) +>this : Symbol(Schema, Decl(schemaCallableReturnMetadata.ts, 4, 1)) + + asNestedTest(): () => void { return () => {}; } +>asNestedTest : Symbol(Schema.asNestedTest, Decl(schemaCallableReturnMetadata.ts, 7, 30)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/schemaCallableReturnMetadata.types b/tsc/testdata/baselines/reference/compiler/schemaCallableReturnMetadata.types new file mode 100644 index 0000000000000..e76b0e7b3ccc2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/schemaCallableReturnMetadata.types @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/schemaCallableReturnMetadata.ts] //// + +=== schemaCallableReturnMetadata.ts === +type Test = (() => void) & { options?: {} }; +>Test : Test +>options : {} | undefined + +interface ISchema { + resolve(): ISchema; +>resolve : () => ISchema + + asNestedTest(): Test; +>asNestedTest : () => Test +} + +class Schema implements ISchema { +>Schema : Schema + + resolve() { return this; } +>resolve : () => this +>this : this + + asNestedTest(): () => void { return () => {}; } +>asNestedTest : () => () => void +>() => {} : () => void +} + diff --git a/tsc/testdata/baselines/reference/compiler/skippedCircularMatcherBases.js b/tsc/testdata/baselines/reference/compiler/skippedCircularMatcherBases.js new file mode 100644 index 0000000000000..375a104f9d327 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/skippedCircularMatcherBases.js @@ -0,0 +1,18 @@ +//// [tests/cases/compiler/skippedCircularMatcherBases.ts] //// + +//// [matchers.d.ts] +interface Expect extends Matchers {} +interface MatcherResult {} +interface Matchers { + containing(value: string): unknown; +} +interface Matchers extends MatcherResult> {} +declare const expect: Expect; + +//// [main.ts] +expect.containing("value"); + + +//// [main.js] +"use strict"; +expect.containing("value"); diff --git a/tsc/testdata/baselines/reference/compiler/skippedCircularMatcherBases.symbols b/tsc/testdata/baselines/reference/compiler/skippedCircularMatcherBases.symbols new file mode 100644 index 0000000000000..26a30f9b928e8 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/skippedCircularMatcherBases.symbols @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/skippedCircularMatcherBases.ts] //// + +=== matchers.d.ts === +interface Expect extends Matchers {} +>Expect : Symbol(Expect, Decl(matchers.d.ts, 0, 0)) +>Matchers : Symbol(Matchers, Decl(matchers.d.ts, 1, 34), Decl(matchers.d.ts, 4, 1)) + +interface MatcherResult {} +>MatcherResult : Symbol(MatcherResult, Decl(matchers.d.ts, 0, 36)) +>Result : Symbol(Result, Decl(matchers.d.ts, 1, 24)) + +interface Matchers { +>Matchers : Symbol(Matchers, Decl(matchers.d.ts, 1, 34), Decl(matchers.d.ts, 4, 1)) + + containing(value: string): unknown; +>containing : Symbol(Matchers.containing, Decl(matchers.d.ts, 2, 20)) +>value : Symbol(value, Decl(matchers.d.ts, 3, 15)) +} +interface Matchers extends MatcherResult> {} +>Matchers : Symbol(Matchers, Decl(matchers.d.ts, 1, 34), Decl(matchers.d.ts, 4, 1)) +>MatcherResult : Symbol(MatcherResult, Decl(matchers.d.ts, 0, 36)) +>ReturnType : Symbol(ReturnType, Decl(lib.es5.d.ts, --, --)) +>expect.containing : Symbol(Matchers.containing, Decl(matchers.d.ts, 2, 20)) +>expect : Symbol(expect, Decl(matchers.d.ts, 6, 13)) +>containing : Symbol(Matchers.containing, Decl(matchers.d.ts, 2, 20)) + +declare const expect: Expect; +>expect : Symbol(expect, Decl(matchers.d.ts, 6, 13)) +>Expect : Symbol(Expect, Decl(matchers.d.ts, 0, 0)) + +=== main.ts === +expect.containing("value"); +>expect.containing : Symbol(Matchers.containing, Decl(matchers.d.ts, 2, 20)) +>expect : Symbol(expect, Decl(matchers.d.ts, 6, 13)) +>containing : Symbol(Matchers.containing, Decl(matchers.d.ts, 2, 20)) + diff --git a/tsc/testdata/baselines/reference/compiler/skippedCircularMatcherBases.types b/tsc/testdata/baselines/reference/compiler/skippedCircularMatcherBases.types new file mode 100644 index 0000000000000..42094033fad85 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/skippedCircularMatcherBases.types @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/skippedCircularMatcherBases.ts] //// + +=== matchers.d.ts === +interface Expect extends Matchers {} +interface MatcherResult {} +interface Matchers { + containing(value: string): unknown; +>containing : (value: string) => unknown +>value : string +} +interface Matchers extends MatcherResult> {} +>expect.containing : (value: string) => unknown +>expect : Expect +>containing : (value: string) => unknown + +declare const expect: Expect; +>expect : Expect + +=== main.ts === +expect.containing("value"); +>expect.containing("value") : unknown +>expect.containing : (value: string) => unknown +>expect : Expect +>containing : (value: string) => unknown +>"value" : "value" + diff --git a/tsc/testdata/baselines/reference/compiler/skippedImplicitHandlerParameters.errors.txt b/tsc/testdata/baselines/reference/compiler/skippedImplicitHandlerParameters.errors.txt new file mode 100644 index 0000000000000..1762af422c8c9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/skippedImplicitHandlerParameters.errors.txt @@ -0,0 +1,22 @@ +main.ts(2,13): error TS2345: Argument of type 'Parameters[0]' is not assignable to parameter of type 'never'. + Type 'any' is not assignable to type 'never'. + + +==== handlers.d.ts (0 errors) ==== + interface FilterHandlers { + update: (value: object) => void; + remove: (value: string) => void; + } + interface ServerHandlers { + save: (value) => "saved"; + } + interface Handlers extends ServerHandlers, FilterHandlers {} + +==== main.ts (1 errors) ==== + function runHandler(handler: T, value: Parameters[0]) { + handler(value); + ~~~~~ +!!! error TS2345: Argument of type 'Parameters[0]' is not assignable to parameter of type 'never'. +!!! error TS2345: Type 'any' is not assignable to type 'never'. + } + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/skippedImplicitHandlerParameters.js b/tsc/testdata/baselines/reference/compiler/skippedImplicitHandlerParameters.js new file mode 100644 index 0000000000000..7758f3d1e9ce2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/skippedImplicitHandlerParameters.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/skippedImplicitHandlerParameters.ts] //// + +//// [handlers.d.ts] +interface FilterHandlers { + update: (value: object) => void; + remove: (value: string) => void; +} +interface ServerHandlers { + save: (value) => "saved"; +} +interface Handlers extends ServerHandlers, FilterHandlers {} + +//// [main.ts] +function runHandler(handler: T, value: Parameters[0]) { + handler(value); +} + + +//// [main.js] +"use strict"; +function runHandler(handler, value) { + handler(value); +} diff --git a/tsc/testdata/baselines/reference/compiler/skippedImplicitHandlerParameters.symbols b/tsc/testdata/baselines/reference/compiler/skippedImplicitHandlerParameters.symbols new file mode 100644 index 0000000000000..4c05441149e8b --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/skippedImplicitHandlerParameters.symbols @@ -0,0 +1,43 @@ +//// [tests/cases/compiler/skippedImplicitHandlerParameters.ts] //// + +=== handlers.d.ts === +interface FilterHandlers { +>FilterHandlers : Symbol(FilterHandlers, Decl(handlers.d.ts, 0, 0)) + + update: (value: object) => void; +>update : Symbol(FilterHandlers.update, Decl(handlers.d.ts, 0, 26)) +>value : Symbol(value, Decl(handlers.d.ts, 1, 13)) + + remove: (value: string) => void; +>remove : Symbol(FilterHandlers.remove, Decl(handlers.d.ts, 1, 36)) +>value : Symbol(value, Decl(handlers.d.ts, 2, 13)) +} +interface ServerHandlers { +>ServerHandlers : Symbol(ServerHandlers, Decl(handlers.d.ts, 3, 1)) + + save: (value) => "saved"; +>save : Symbol(ServerHandlers.save, Decl(handlers.d.ts, 4, 26)) +>value : Symbol(value, Decl(handlers.d.ts, 5, 11)) +} +interface Handlers extends ServerHandlers, FilterHandlers {} +>Handlers : Symbol(Handlers, Decl(handlers.d.ts, 6, 1)) +>ServerHandlers : Symbol(ServerHandlers, Decl(handlers.d.ts, 3, 1)) +>FilterHandlers : Symbol(FilterHandlers, Decl(handlers.d.ts, 0, 0)) + +=== main.ts === +function runHandler(handler: T, value: Parameters[0]) { +>runHandler : Symbol(runHandler, Decl(main.ts, 0, 0)) +>T : Symbol(T, Decl(main.ts, 0, 20)) +>Handlers : Symbol(Handlers, Decl(handlers.d.ts, 6, 1)) +>Handlers : Symbol(Handlers, Decl(handlers.d.ts, 6, 1)) +>handler : Symbol(handler, Decl(main.ts, 0, 56)) +>T : Symbol(T, Decl(main.ts, 0, 20)) +>value : Symbol(value, Decl(main.ts, 0, 67)) +>Parameters : Symbol(Parameters, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(main.ts, 0, 20)) + + handler(value); +>handler : Symbol(handler, Decl(main.ts, 0, 56)) +>value : Symbol(value, Decl(main.ts, 0, 67)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/skippedImplicitHandlerParameters.types b/tsc/testdata/baselines/reference/compiler/skippedImplicitHandlerParameters.types new file mode 100644 index 0000000000000..02ef9ffba65b6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/skippedImplicitHandlerParameters.types @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/skippedImplicitHandlerParameters.ts] //// + +=== handlers.d.ts === +interface FilterHandlers { + update: (value: object) => void; +>update : (value: object) => void +>value : object + + remove: (value: string) => void; +>remove : (value: string) => void +>value : string +} +interface ServerHandlers { + save: (value) => "saved"; +>save : (value: any) => "saved" +>value : any +} +interface Handlers extends ServerHandlers, FilterHandlers {} + +=== main.ts === +function runHandler(handler: T, value: Parameters[0]) { +>runHandler : (handler: T, value: Parameters[0]) => void +>handler : T +>value : Parameters[0] + + handler(value); +>handler(value) : void | "saved" +>handler : ((value: object) => void) | ((value: string) => void) | ((value: any) => "saved") +>value : Parameters[0] +} + diff --git a/tsc/testdata/baselines/reference/compiler/starDefaultAssignmentCollision.js b/tsc/testdata/baselines/reference/compiler/starDefaultAssignmentCollision.js new file mode 100644 index 0000000000000..014733382b169 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/starDefaultAssignmentCollision.js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/starDefaultAssignmentCollision.ts] //// + +//// [first.ts] +const first = 1; +export default first; + +//// [second.ts] +const second = 2; +export default second; + +//// [barrel.ts] +export * from "./first"; +export * from "./second"; + + +//// [first.js] +const first = 1; +export default first; +//// [second.js] +const second = 2; +export default second; +//// [barrel.js] +export * from "./first"; +export * from "./second"; diff --git a/tsc/testdata/baselines/reference/compiler/starDefaultAssignmentCollision.symbols b/tsc/testdata/baselines/reference/compiler/starDefaultAssignmentCollision.symbols new file mode 100644 index 0000000000000..9fe4d08343619 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/starDefaultAssignmentCollision.symbols @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/starDefaultAssignmentCollision.ts] //// + +=== first.ts === +const first = 1; +>first : Symbol(first, Decl(first.ts, 0, 5)) + +export default first; +>first : Symbol(first, Decl(first.ts, 0, 5)) + +=== second.ts === +const second = 2; +>second : Symbol(second, Decl(second.ts, 0, 5)) + +export default second; +>second : Symbol(second, Decl(second.ts, 0, 5)) + +=== barrel.ts === + +export * from "./first"; +export * from "./second"; + diff --git a/tsc/testdata/baselines/reference/compiler/starDefaultAssignmentCollision.types b/tsc/testdata/baselines/reference/compiler/starDefaultAssignmentCollision.types new file mode 100644 index 0000000000000..5d58137acde51 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/starDefaultAssignmentCollision.types @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/starDefaultAssignmentCollision.ts] //// + +=== first.ts === +const first = 1; +>first : 1 +>1 : 1 + +export default first; +>first : 1 + +=== second.ts === +const second = 2; +>second : 2 +>2 : 2 + +export default second; +>second : 2 + +=== barrel.ts === + +export * from "./first"; +export * from "./second"; + diff --git a/tsc/testdata/baselines/reference/compiler/strictSupertypeConcat.symbols b/tsc/testdata/baselines/reference/compiler/strictSupertypeConcat.symbols new file mode 100644 index 0000000000000..61a3ebe1611e5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/strictSupertypeConcat.symbols @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/strictSupertypeConcat.ts] //// + +=== strictSupertypeConcat.ts === +declare class User { +>User : Symbol(User, Decl(strictSupertypeConcat.ts, 0, 0)) + + get initial(): string; +>initial : Symbol(User.initial, Decl(strictSupertypeConcat.ts, 0, 20)) +} +declare class Group { +>Group : Symbol(Group, Decl(strictSupertypeConcat.ts, 2, 1)) + + memberCount: number; +>memberCount : Symbol(Group.memberCount, Decl(strictSupertypeConcat.ts, 3, 21)) +} +interface Suggestion { +>Suggestion : Symbol(Suggestion, Decl(strictSupertypeConcat.ts, 5, 1)) + + initial?: string; +>initial : Symbol(Suggestion.initial, Decl(strictSupertypeConcat.ts, 6, 22)) +} +type Many = Value | readonly Value[]; +>Many : Symbol(Many, Decl(strictSupertypeConcat.ts, 8, 1)) +>Value : Symbol(Value, Decl(strictSupertypeConcat.ts, 9, 10)) +>Value : Symbol(Value, Decl(strictSupertypeConcat.ts, 9, 10)) +>Value : Symbol(Value, Decl(strictSupertypeConcat.ts, 9, 10)) + +declare function concat(...values: Many[]): Value[]; +>concat : Symbol(concat, Decl(strictSupertypeConcat.ts, 9, 44)) +>Value : Symbol(Value, Decl(strictSupertypeConcat.ts, 11, 24)) +>values : Symbol(values, Decl(strictSupertypeConcat.ts, 11, 31)) +>Many : Symbol(Many, Decl(strictSupertypeConcat.ts, 8, 1)) +>Value : Symbol(Value, Decl(strictSupertypeConcat.ts, 11, 24)) +>Value : Symbol(Value, Decl(strictSupertypeConcat.ts, 11, 24)) + +declare const pending: User[]; +>pending : Symbol(pending, Decl(strictSupertypeConcat.ts, 12, 13)) +>User : Symbol(User, Decl(strictSupertypeConcat.ts, 0, 0)) + +declare const suggestions: (Group | Suggestion)[]; +>suggestions : Symbol(suggestions, Decl(strictSupertypeConcat.ts, 13, 13)) +>Group : Symbol(Group, Decl(strictSupertypeConcat.ts, 2, 1)) +>Suggestion : Symbol(Suggestion, Decl(strictSupertypeConcat.ts, 5, 1)) + +const items = concat(pending, suggestions); +>items : Symbol(items, Decl(strictSupertypeConcat.ts, 15, 5)) +>concat : Symbol(concat, Decl(strictSupertypeConcat.ts, 9, 44)) +>pending : Symbol(pending, Decl(strictSupertypeConcat.ts, 12, 13)) +>suggestions : Symbol(suggestions, Decl(strictSupertypeConcat.ts, 13, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/strictSupertypeConcat.types b/tsc/testdata/baselines/reference/compiler/strictSupertypeConcat.types new file mode 100644 index 0000000000000..30d51285c46cc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/strictSupertypeConcat.types @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/strictSupertypeConcat.ts] //// + +=== strictSupertypeConcat.ts === +declare class User { +>User : User + + get initial(): string; +>initial : string +} +declare class Group { +>Group : Group + + memberCount: number; +>memberCount : number +} +interface Suggestion { + initial?: string; +>initial : string | undefined +} +type Many = Value | readonly Value[]; +>Many : Many + +declare function concat(...values: Many[]): Value[]; +>concat : (...values: Many[]) => Value[] +>values : Many[] + +declare const pending: User[]; +>pending : User[] + +declare const suggestions: (Group | Suggestion)[]; +>suggestions : (Group | Suggestion)[] + +const items = concat(pending, suggestions); +>items : (Group | Suggestion)[] +>concat(pending, suggestions) : (Group | Suggestion)[] +>concat : (...values: Many[]) => Value[] +>pending : User[] +>suggestions : (Group | Suggestion)[] + diff --git a/tsc/testdata/baselines/reference/compiler/strictSupertypeInjection.symbols b/tsc/testdata/baselines/reference/compiler/strictSupertypeInjection.symbols new file mode 100644 index 0000000000000..5f922fa38b7f6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/strictSupertypeInjection.symbols @@ -0,0 +1,70 @@ +//// [tests/cases/compiler/strictSupertypeInjection.ts] //// + +=== strictSupertypeInjection.ts === +interface Reference { +>Reference : Symbol(Reference, Decl(strictSupertypeInjection.ts, 0, 0)) +>Value : Symbol(Value, Decl(strictSupertypeInjection.ts, 0, 20)) + + get value(): Value; +>value : Symbol(Reference.value, Decl(strictSupertypeInjection.ts, 0, 28), Decl(strictSupertypeInjection.ts, 1, 23)) +>Value : Symbol(Value, Decl(strictSupertypeInjection.ts, 0, 20)) + + set value(value: Value); +>value : Symbol(Reference.value, Decl(strictSupertypeInjection.ts, 0, 28), Decl(strictSupertypeInjection.ts, 1, 23)) +>value : Symbol(value, Decl(strictSupertypeInjection.ts, 2, 14)) +>Value : Symbol(Value, Decl(strictSupertypeInjection.ts, 0, 20)) +} +interface ComputedReference extends Reference { +>ComputedReference : Symbol(ComputedReference, Decl(strictSupertypeInjection.ts, 3, 1)) +>Value : Symbol(Value, Decl(strictSupertypeInjection.ts, 4, 28)) +>Reference : Symbol(Reference, Decl(strictSupertypeInjection.ts, 0, 0)) +>Value : Symbol(Value, Decl(strictSupertypeInjection.ts, 4, 28)) + + readonly value: Value; +>value : Symbol(ComputedReference.value, Decl(strictSupertypeInjection.ts, 4, 61)) +>Value : Symbol(Value, Decl(strictSupertypeInjection.ts, 4, 28)) + + effect: unknown; +>effect : Symbol(ComputedReference.effect, Decl(strictSupertypeInjection.ts, 5, 26)) +} +interface InjectionConstraint {} +>InjectionConstraint : Symbol(InjectionConstraint, Decl(strictSupertypeInjection.ts, 7, 1)) +>Value : Symbol(Value, Decl(strictSupertypeInjection.ts, 8, 30)) + +type InjectionKey = symbol & InjectionConstraint; +>InjectionKey : Symbol(InjectionKey, Decl(strictSupertypeInjection.ts, 8, 39)) +>Value : Symbol(Value, Decl(strictSupertypeInjection.ts, 9, 18)) +>InjectionConstraint : Symbol(InjectionConstraint, Decl(strictSupertypeInjection.ts, 7, 1)) +>Value : Symbol(Value, Decl(strictSupertypeInjection.ts, 9, 18)) + +declare function inject(key: InjectionKey | string, fallback: Value): Value; +>inject : Symbol(inject, Decl(strictSupertypeInjection.ts, 9, 63)) +>Value : Symbol(Value, Decl(strictSupertypeInjection.ts, 11, 24)) +>key : Symbol(key, Decl(strictSupertypeInjection.ts, 11, 31)) +>InjectionKey : Symbol(InjectionKey, Decl(strictSupertypeInjection.ts, 8, 39)) +>Value : Symbol(Value, Decl(strictSupertypeInjection.ts, 11, 24)) +>fallback : Symbol(fallback, Decl(strictSupertypeInjection.ts, 11, 65)) +>Value : Symbol(Value, Decl(strictSupertypeInjection.ts, 11, 24)) +>Value : Symbol(Value, Decl(strictSupertypeInjection.ts, 11, 24)) + +declare function ref(): Reference; +>ref : Symbol(ref, Decl(strictSupertypeInjection.ts, 11, 90)) +>Value : Symbol(Value, Decl(strictSupertypeInjection.ts, 12, 21)) +>Reference : Symbol(Reference, Decl(strictSupertypeInjection.ts, 0, 0)) +>Value : Symbol(Value, Decl(strictSupertypeInjection.ts, 12, 21)) + +declare const key: InjectionKey<{ visibleIds: ComputedReference }>; +>key : Symbol(key, Decl(strictSupertypeInjection.ts, 13, 13)) +>InjectionKey : Symbol(InjectionKey, Decl(strictSupertypeInjection.ts, 8, 39)) +>visibleIds : Symbol(visibleIds, Decl(strictSupertypeInjection.ts, 13, 33)) +>ComputedReference : Symbol(ComputedReference, Decl(strictSupertypeInjection.ts, 3, 1)) + +const visibleIds = inject(key, { visibleIds: ref() }).visibleIds; +>visibleIds : Symbol(visibleIds, Decl(strictSupertypeInjection.ts, 15, 5)) +>inject(key, { visibleIds: ref() }).visibleIds : Symbol(visibleIds, Decl(strictSupertypeInjection.ts, 15, 32)) +>inject : Symbol(inject, Decl(strictSupertypeInjection.ts, 9, 63)) +>key : Symbol(key, Decl(strictSupertypeInjection.ts, 13, 13)) +>visibleIds : Symbol(visibleIds, Decl(strictSupertypeInjection.ts, 15, 32)) +>ref : Symbol(ref, Decl(strictSupertypeInjection.ts, 11, 90)) +>visibleIds : Symbol(visibleIds, Decl(strictSupertypeInjection.ts, 15, 32)) + diff --git a/tsc/testdata/baselines/reference/compiler/strictSupertypeInjection.types b/tsc/testdata/baselines/reference/compiler/strictSupertypeInjection.types new file mode 100644 index 0000000000000..af1577777c2ce --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/strictSupertypeInjection.types @@ -0,0 +1,46 @@ +//// [tests/cases/compiler/strictSupertypeInjection.ts] //// + +=== strictSupertypeInjection.ts === +interface Reference { + get value(): Value; +>value : Value + + set value(value: Value); +>value : Value +>value : Value +} +interface ComputedReference extends Reference { + readonly value: Value; +>value : Value + + effect: unknown; +>effect : unknown +} +interface InjectionConstraint {} +type InjectionKey = symbol & InjectionConstraint; +>InjectionKey : InjectionKey + +declare function inject(key: InjectionKey | string, fallback: Value): Value; +>inject : (key: InjectionKey | string, fallback: Value) => Value +>key : string | InjectionKey +>fallback : Value + +declare function ref(): Reference; +>ref : () => Reference + +declare const key: InjectionKey<{ visibleIds: ComputedReference }>; +>key : InjectionKey<{ visibleIds: ComputedReference; }> +>visibleIds : ComputedReference + +const visibleIds = inject(key, { visibleIds: ref() }).visibleIds; +>visibleIds : Reference +>inject(key, { visibleIds: ref() }).visibleIds : Reference +>inject(key, { visibleIds: ref() }) : { visibleIds: Reference; } +>inject : (key: InjectionKey | string, fallback: Value) => Value +>key : InjectionKey<{ visibleIds: ComputedReference; }> +>{ visibleIds: ref() } : { visibleIds: Reference; } +>visibleIds : Reference +>ref() : Reference +>ref : () => Reference +>visibleIds : Reference + diff --git a/tsc/testdata/baselines/reference/compiler/strictSupertypeSchema.errors.txt b/tsc/testdata/baselines/reference/compiler/strictSupertypeSchema.errors.txt new file mode 100644 index 0000000000000..e0e94f8a7e4e4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/strictSupertypeSchema.errors.txt @@ -0,0 +1,16 @@ +strictSupertypeSchema.ts(9,8): error TS2339: Property '$ref' does not exist on type '{}'. + + +==== strictSupertypeSchema.ts (1 errors) ==== + interface Schema { + [name: string]: any; + } + + declare function choose(...callbacks: (() => Result)[]): Result; + declare const schema: Schema; + + const result = choose(() => ({}), () => schema); + result.$ref; + ~~~~ +!!! error TS2339: Property '$ref' does not exist on type '{}'. + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/strictSupertypeSchema.symbols b/tsc/testdata/baselines/reference/compiler/strictSupertypeSchema.symbols new file mode 100644 index 0000000000000..cd264c4627775 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/strictSupertypeSchema.symbols @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/strictSupertypeSchema.ts] //// + +=== strictSupertypeSchema.ts === +interface Schema { +>Schema : Symbol(Schema, Decl(strictSupertypeSchema.ts, 0, 0)) + + [name: string]: any; +>name : Symbol(name, Decl(strictSupertypeSchema.ts, 1, 5)) +} + +declare function choose(...callbacks: (() => Result)[]): Result; +>choose : Symbol(choose, Decl(strictSupertypeSchema.ts, 2, 1)) +>Result : Symbol(Result, Decl(strictSupertypeSchema.ts, 4, 24)) +>callbacks : Symbol(callbacks, Decl(strictSupertypeSchema.ts, 4, 32)) +>Result : Symbol(Result, Decl(strictSupertypeSchema.ts, 4, 24)) +>Result : Symbol(Result, Decl(strictSupertypeSchema.ts, 4, 24)) + +declare const schema: Schema; +>schema : Symbol(schema, Decl(strictSupertypeSchema.ts, 5, 13)) +>Schema : Symbol(Schema, Decl(strictSupertypeSchema.ts, 0, 0)) + +const result = choose(() => ({}), () => schema); +>result : Symbol(result, Decl(strictSupertypeSchema.ts, 7, 5)) +>choose : Symbol(choose, Decl(strictSupertypeSchema.ts, 2, 1)) +>schema : Symbol(schema, Decl(strictSupertypeSchema.ts, 5, 13)) + +result.$ref; +>result : Symbol(result, Decl(strictSupertypeSchema.ts, 7, 5)) + diff --git a/tsc/testdata/baselines/reference/compiler/strictSupertypeSchema.types b/tsc/testdata/baselines/reference/compiler/strictSupertypeSchema.types new file mode 100644 index 0000000000000..bf7ca8120d85f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/strictSupertypeSchema.types @@ -0,0 +1,30 @@ +//// [tests/cases/compiler/strictSupertypeSchema.ts] //// + +=== strictSupertypeSchema.ts === +interface Schema { + [name: string]: any; +>name : string +} + +declare function choose(...callbacks: (() => Result)[]): Result; +>choose : (...callbacks: (() => Result)[]) => Result +>callbacks : (() => Result)[] + +declare const schema: Schema; +>schema : Schema + +const result = choose(() => ({}), () => schema); +>result : {} +>choose(() => ({}), () => schema) : {} +>choose : (...callbacks: (() => Result)[]) => Result +>() => ({}) : () => {} +>({}) : {} +>{} : {} +>() => schema : () => Schema +>schema : Schema + +result.$ref; +>result.$ref : any +>result : {} +>$ref : any + diff --git a/tsc/testdata/baselines/reference/compiler/syntheticDefaultCallbackContext.symbols b/tsc/testdata/baselines/reference/compiler/syntheticDefaultCallbackContext.symbols new file mode 100644 index 0000000000000..8872f8755005a --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/syntheticDefaultCallbackContext.symbols @@ -0,0 +1,46 @@ +//// [tests/cases/compiler/syntheticDefaultCallbackContext.ts] //// + +=== stream.d.ts === +export interface Stream { +>Stream : Symbol(Stream, Decl(stream.d.ts, 0, 0)) + + emit(event: string, data?: any): void; +>emit : Symbol(Stream.emit, Decl(stream.d.ts, 0, 25)) +>event : Symbol(event, Decl(stream.d.ts, 1, 9)) +>data : Symbol(data, Decl(stream.d.ts, 1, 23)) +} +export function through(write?: (this: Stream, data: any) => void, end?: (this: Stream) => void): Stream; +>through : Symbol(through, Decl(stream.d.ts, 2, 1)) +>write : Symbol(write, Decl(stream.d.ts, 3, 24)) +>this : Symbol(this, Decl(stream.d.ts, 3, 33)) +>Stream : Symbol(Stream, Decl(stream.d.ts, 0, 0)) +>data : Symbol(data, Decl(stream.d.ts, 3, 46)) +>end : Symbol(end, Decl(stream.d.ts, 3, 66)) +>this : Symbol(this, Decl(stream.d.ts, 3, 74)) +>Stream : Symbol(Stream, Decl(stream.d.ts, 0, 0)) +>Stream : Symbol(Stream, Decl(stream.d.ts, 0, 0)) + +=== main.ts === +import stream from "./stream"; +>stream : Symbol(stream, Decl(main.ts, 0, 6)) + +stream.through(function (data) { +>stream.through : Symbol(stream.through, Decl(stream.d.ts, 2, 1)) +>stream : Symbol(stream, Decl(main.ts, 0, 6)) +>through : Symbol(stream.through, Decl(stream.d.ts, 2, 1)) +>data : Symbol(data, Decl(main.ts, 1, 25)) + + this.emit("data", data); +>this.emit : Symbol(stream.Stream.emit, Decl(stream.d.ts, 0, 25)) +>this : Symbol(this, Decl(stream.d.ts, 3, 33)) +>emit : Symbol(stream.Stream.emit, Decl(stream.d.ts, 0, 25)) +>data : Symbol(data, Decl(main.ts, 1, 25)) + +}, function () { + this.emit("end"); +>this.emit : Symbol(stream.Stream.emit, Decl(stream.d.ts, 0, 25)) +>this : Symbol(this, Decl(stream.d.ts, 3, 74)) +>emit : Symbol(stream.Stream.emit, Decl(stream.d.ts, 0, 25)) + +}); + diff --git a/tsc/testdata/baselines/reference/compiler/syntheticDefaultCallbackContext.types b/tsc/testdata/baselines/reference/compiler/syntheticDefaultCallbackContext.types new file mode 100644 index 0000000000000..f25a0e1703c11 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/syntheticDefaultCallbackContext.types @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/syntheticDefaultCallbackContext.ts] //// + +=== stream.d.ts === +export interface Stream { + emit(event: string, data?: any): void; +>emit : (event: string, data?: any) => void +>event : string +>data : any +} +export function through(write?: (this: Stream, data: any) => void, end?: (this: Stream) => void): Stream; +>through : (write?: (this: Stream, data: any) => void, end?: (this: Stream) => void) => Stream +>write : ((this: Stream, data: any) => void) | undefined +>this : Stream +>data : any +>end : ((this: Stream) => void) | undefined +>this : Stream + +=== main.ts === +import stream from "./stream"; +>stream : typeof stream + +stream.through(function (data) { +>stream.through(function (data) { this.emit("data", data);}, function () { this.emit("end");}) : stream.Stream +>stream.through : (write?: (this: stream.Stream, data: any) => void, end?: (this: stream.Stream) => void) => stream.Stream +>stream : typeof stream +>through : (write?: (this: stream.Stream, data: any) => void, end?: (this: stream.Stream) => void) => stream.Stream +>function (data) { this.emit("data", data);} : (this: stream.Stream, data: any) => void +>data : any + + this.emit("data", data); +>this.emit("data", data) : void +>this.emit : (event: string, data?: any) => void +>this : stream.Stream +>emit : (event: string, data?: any) => void +>"data" : "data" +>data : any + +}, function () { +>function () { this.emit("end");} : (this: stream.Stream) => void + + this.emit("end"); +>this.emit("end") : void +>this.emit : (event: string, data?: any) => void +>this : stream.Stream +>emit : (event: string, data?: any) => void +>"end" : "end" + +}); + diff --git a/tsc/testdata/baselines/reference/compiler/templateIndexedScopeOptions.symbols b/tsc/testdata/baselines/reference/compiler/templateIndexedScopeOptions.symbols new file mode 100644 index 0000000000000..9aad208ec6216 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/templateIndexedScopeOptions.symbols @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/templateIndexedScopeOptions.ts] //// + +=== templateIndexedScopeOptions.ts === +type Attributes = { name?: string } & { [path: `$${string}.${string}$`]: unknown }; +>Attributes : Symbol(Attributes, Decl(templateIndexedScopeOptions.ts, 0, 0)) +>name : Symbol(name, Decl(templateIndexedScopeOptions.ts, 0, 19)) +>path : Symbol(path, Decl(templateIndexedScopeOptions.ts, 0, 41)) + +declare function scope(options: Attributes | { method: readonly [string, ...unknown[]] }): void; +>scope : Symbol(scope, Decl(templateIndexedScopeOptions.ts, 0, 83)) +>options : Symbol(options, Decl(templateIndexedScopeOptions.ts, 1, 23)) +>Attributes : Symbol(Attributes, Decl(templateIndexedScopeOptions.ts, 0, 0)) +>method : Symbol(method, Decl(templateIndexedScopeOptions.ts, 1, 46)) + +const options = { method: ["list", { id: 1 }] }; +>options : Symbol(options, Decl(templateIndexedScopeOptions.ts, 2, 5)) +>method : Symbol(method, Decl(templateIndexedScopeOptions.ts, 2, 17)) +>id : Symbol(id, Decl(templateIndexedScopeOptions.ts, 2, 36)) + +scope(options); +>scope : Symbol(scope, Decl(templateIndexedScopeOptions.ts, 0, 83)) +>options : Symbol(options, Decl(templateIndexedScopeOptions.ts, 2, 5)) + diff --git a/tsc/testdata/baselines/reference/compiler/templateIndexedScopeOptions.types b/tsc/testdata/baselines/reference/compiler/templateIndexedScopeOptions.types new file mode 100644 index 0000000000000..13851d4ca05f4 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/templateIndexedScopeOptions.types @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/templateIndexedScopeOptions.ts] //// + +=== templateIndexedScopeOptions.ts === +type Attributes = { name?: string } & { [path: `$${string}.${string}$`]: unknown }; +>Attributes : Attributes +>name : string | undefined +>path : `$${string}.${string}$` + +declare function scope(options: Attributes | { method: readonly [string, ...unknown[]] }): void; +>scope : (options: Attributes | { method: readonly [string, ...unknown[]]; }) => void +>options : { method: readonly [string, ...unknown[]]; } | Attributes +>method : readonly [string, ...unknown[]] + +const options = { method: ["list", { id: 1 }] }; +>options : { method: (string | { id: number; })[]; } +>{ method: ["list", { id: 1 }] } : { method: (string | { id: number; })[]; } +>method : (string | { id: number; })[] +>["list", { id: 1 }] : (string | { id: number; })[] +>"list" : "list" +>{ id: 1 } : { id: number; } +>id : number +>1 : 1 + +scope(options); +>scope(options) : void +>scope : (options: Attributes | { method: readonly [string, ...unknown[]]; }) => void +>options : { method: (string | { id: number; })[]; } + diff --git a/tsc/testdata/baselines/reference/compiler/transitiveStarDefaultCollision.js b/tsc/testdata/baselines/reference/compiler/transitiveStarDefaultCollision.js new file mode 100644 index 0000000000000..10719dd7987c6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/transitiveStarDefaultCollision.js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/transitiveStarDefaultCollision.ts] //// + +//// [first.ts] +export default 1; + +//// [second.ts] +export default 2; + +//// [nested.ts] +export * from "./first"; + +//// [barrel.ts] +export * from "./nested"; +export * from "./second"; + + +//// [first.js] +export default 1; +//// [second.js] +export default 2; +//// [nested.js] +export * from "./first"; +//// [barrel.js] +export * from "./nested"; +export * from "./second"; diff --git a/tsc/testdata/baselines/reference/compiler/transitiveStarDefaultCollision.symbols b/tsc/testdata/baselines/reference/compiler/transitiveStarDefaultCollision.symbols new file mode 100644 index 0000000000000..418fbd888d8f5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/transitiveStarDefaultCollision.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/transitiveStarDefaultCollision.ts] //// + +=== first.ts === + +export default 1; + +=== second.ts === + +export default 2; + +=== nested.ts === + +export * from "./first"; + +=== barrel.ts === + +export * from "./nested"; +export * from "./second"; + diff --git a/tsc/testdata/baselines/reference/compiler/transitiveStarDefaultCollision.types b/tsc/testdata/baselines/reference/compiler/transitiveStarDefaultCollision.types new file mode 100644 index 0000000000000..418fbd888d8f5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/transitiveStarDefaultCollision.types @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/transitiveStarDefaultCollision.ts] //// + +=== first.ts === + +export default 1; + +=== second.ts === + +export default 2; + +=== nested.ts === + +export * from "./first"; + +=== barrel.ts === + +export * from "./nested"; +export * from "./second"; + diff --git a/tsc/testdata/baselines/reference/compiler/typeOnlyStarDefaultCollision.js b/tsc/testdata/baselines/reference/compiler/typeOnlyStarDefaultCollision.js new file mode 100644 index 0000000000000..6da804d8b3fa0 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/typeOnlyStarDefaultCollision.js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/typeOnlyStarDefaultCollision.ts] //// + +//// [first.ts] +export default 1; + +//// [second.ts] +export default 2; + +//// [barrel.ts] +export type * from "./first"; +export type * from "./second"; + + +//// [first.js] +export default 1; +//// [second.js] +export default 2; +//// [barrel.js] +export {}; diff --git a/tsc/testdata/baselines/reference/compiler/typeOnlyStarDefaultCollision.symbols b/tsc/testdata/baselines/reference/compiler/typeOnlyStarDefaultCollision.symbols new file mode 100644 index 0000000000000..2e8746d8e7772 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/typeOnlyStarDefaultCollision.symbols @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/typeOnlyStarDefaultCollision.ts] //// + +=== first.ts === + +export default 1; + +=== second.ts === + +export default 2; + +=== barrel.ts === + +export type * from "./first"; +export type * from "./second"; + diff --git a/tsc/testdata/baselines/reference/compiler/typeOnlyStarDefaultCollision.types b/tsc/testdata/baselines/reference/compiler/typeOnlyStarDefaultCollision.types new file mode 100644 index 0000000000000..2e8746d8e7772 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/typeOnlyStarDefaultCollision.types @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/typeOnlyStarDefaultCollision.ts] //// + +=== first.ts === + +export default 1; + +=== second.ts === + +export default 2; + +=== barrel.ts === + +export type * from "./first"; +export type * from "./second"; + diff --git a/tsc/testdata/baselines/reference/compiler/typeOnlySyntheticDefaultImport.symbols b/tsc/testdata/baselines/reference/compiler/typeOnlySyntheticDefaultImport.symbols new file mode 100644 index 0000000000000..5f0daa00b8b8f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/typeOnlySyntheticDefaultImport.symbols @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/typeOnlySyntheticDefaultImport.ts] //// + +=== library.d.ts === +export function render(): void; +>render : Symbol(render, Decl(library.d.ts, 0, 0)) + +=== main.ts === +import type { default as Library } from "./library"; +>default : Symbol(Library, Decl(library.d.ts, 0, 0)) +>Library : Symbol(Library, Decl(main.ts, 0, 13)) + +type LibraryType = typeof Library; +>LibraryType : Symbol(LibraryType, Decl(main.ts, 0, 52)) +>Library : Symbol(Library, Decl(main.ts, 0, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/typeOnlySyntheticDefaultImport.types b/tsc/testdata/baselines/reference/compiler/typeOnlySyntheticDefaultImport.types new file mode 100644 index 0000000000000..478a80931725f --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/typeOnlySyntheticDefaultImport.types @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/typeOnlySyntheticDefaultImport.ts] //// + +=== library.d.ts === +export function render(): void; +>render : () => void + +=== main.ts === +import type { default as Library } from "./library"; +>default : typeof Library +>Library : any + +type LibraryType = typeof Library; +>LibraryType : typeof Library +>Library : typeof Library + diff --git a/tsc/testdata/baselines/reference/compiler/undefinedPropertyTruthyReceiver.js b/tsc/testdata/baselines/reference/compiler/undefinedPropertyTruthyReceiver.js new file mode 100644 index 0000000000000..a317eccb94e84 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/undefinedPropertyTruthyReceiver.js @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/undefinedPropertyTruthyReceiver.ts] //// + +//// [undefinedPropertyTruthyReceiver.ts] +const state = { error: undefined }; +const renderedError = state.error ? state.error : ""; + + +//// [undefinedPropertyTruthyReceiver.js] +"use strict"; +const state = { error: undefined }; +const renderedError = state.error ? state.error : ""; diff --git a/tsc/testdata/baselines/reference/compiler/undefinedPropertyTruthyReceiver.symbols b/tsc/testdata/baselines/reference/compiler/undefinedPropertyTruthyReceiver.symbols new file mode 100644 index 0000000000000..fb40cbd4b9268 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/undefinedPropertyTruthyReceiver.symbols @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/undefinedPropertyTruthyReceiver.ts] //// + +=== undefinedPropertyTruthyReceiver.ts === +const state = { error: undefined }; +>state : Symbol(state, Decl(undefinedPropertyTruthyReceiver.ts, 0, 5)) +>error : Symbol(error, Decl(undefinedPropertyTruthyReceiver.ts, 0, 15)) +>undefined : Symbol(undefined) + +const renderedError = state.error ? state.error : ""; +>renderedError : Symbol(renderedError, Decl(undefinedPropertyTruthyReceiver.ts, 1, 5)) +>state.error : Symbol(error, Decl(undefinedPropertyTruthyReceiver.ts, 0, 15)) +>state : Symbol(state, Decl(undefinedPropertyTruthyReceiver.ts, 0, 5)) +>error : Symbol(error, Decl(undefinedPropertyTruthyReceiver.ts, 0, 15)) +>state.error : Symbol(error, Decl(undefinedPropertyTruthyReceiver.ts, 0, 15)) +>state : Symbol(state, Decl(undefinedPropertyTruthyReceiver.ts, 0, 5)) +>error : Symbol(error, Decl(undefinedPropertyTruthyReceiver.ts, 0, 15)) + diff --git a/tsc/testdata/baselines/reference/compiler/undefinedPropertyTruthyReceiver.types b/tsc/testdata/baselines/reference/compiler/undefinedPropertyTruthyReceiver.types new file mode 100644 index 0000000000000..5f1307a448055 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/undefinedPropertyTruthyReceiver.types @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/undefinedPropertyTruthyReceiver.ts] //// + +=== undefinedPropertyTruthyReceiver.ts === +const state = { error: undefined }; +>state : { error: undefined; } +>{ error: undefined } : { error: undefined; } +>error : undefined +>undefined : undefined + +const renderedError = state.error ? state.error : ""; +>renderedError : "" +>state.error ? state.error : "" : "" +>state.error : undefined +>state : { error: undefined; } +>error : undefined +>state.error : never +>state : { error: undefined; } +>error : never +>"" : "" + diff --git a/tsc/testdata/baselines/reference/compiler/unknownAfterTypeofEarlyReturn.js b/tsc/testdata/baselines/reference/compiler/unknownAfterTypeofEarlyReturn.js new file mode 100644 index 0000000000000..a20fffed24340 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/unknownAfterTypeofEarlyReturn.js @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/unknownAfterTypeofEarlyReturn.ts] //// + +//// [unknownAfterTypeofEarlyReturn.ts] +declare function fromString(value: string): number; +declare function fromBigint(value: bigint): number; +declare function fromNumber(value: number): boolean; +function coerce(value: unknown) { + if (typeof value === "boolean") return value; + if (typeof value === "string") return fromString(value); + if (typeof value === "bigint") return fromBigint(value); + if (typeof value === "number") return fromNumber(value); +} + + +//// [unknownAfterTypeofEarlyReturn.js] +"use strict"; +function coerce(value) { + if (typeof value === "boolean") + return value; + if (typeof value === "string") + return fromString(value); + if (typeof value === "bigint") + return fromBigint(value); + if (typeof value === "number") + return fromNumber(value); +} diff --git a/tsc/testdata/baselines/reference/compiler/unknownAfterTypeofEarlyReturn.symbols b/tsc/testdata/baselines/reference/compiler/unknownAfterTypeofEarlyReturn.symbols new file mode 100644 index 0000000000000..b0bc1de980cd1 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/unknownAfterTypeofEarlyReturn.symbols @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/unknownAfterTypeofEarlyReturn.ts] //// + +=== unknownAfterTypeofEarlyReturn.ts === +declare function fromString(value: string): number; +>fromString : Symbol(fromString, Decl(unknownAfterTypeofEarlyReturn.ts, 0, 0)) +>value : Symbol(value, Decl(unknownAfterTypeofEarlyReturn.ts, 0, 28)) + +declare function fromBigint(value: bigint): number; +>fromBigint : Symbol(fromBigint, Decl(unknownAfterTypeofEarlyReturn.ts, 0, 51)) +>value : Symbol(value, Decl(unknownAfterTypeofEarlyReturn.ts, 1, 28)) + +declare function fromNumber(value: number): boolean; +>fromNumber : Symbol(fromNumber, Decl(unknownAfterTypeofEarlyReturn.ts, 1, 51)) +>value : Symbol(value, Decl(unknownAfterTypeofEarlyReturn.ts, 2, 28)) + +function coerce(value: unknown) { +>coerce : Symbol(coerce, Decl(unknownAfterTypeofEarlyReturn.ts, 2, 52)) +>value : Symbol(value, Decl(unknownAfterTypeofEarlyReturn.ts, 3, 16)) + + if (typeof value === "boolean") return value; +>value : Symbol(value, Decl(unknownAfterTypeofEarlyReturn.ts, 3, 16)) +>value : Symbol(value, Decl(unknownAfterTypeofEarlyReturn.ts, 3, 16)) + + if (typeof value === "string") return fromString(value); +>value : Symbol(value, Decl(unknownAfterTypeofEarlyReturn.ts, 3, 16)) +>fromString : Symbol(fromString, Decl(unknownAfterTypeofEarlyReturn.ts, 0, 0)) +>value : Symbol(value, Decl(unknownAfterTypeofEarlyReturn.ts, 3, 16)) + + if (typeof value === "bigint") return fromBigint(value); +>value : Symbol(value, Decl(unknownAfterTypeofEarlyReturn.ts, 3, 16)) +>fromBigint : Symbol(fromBigint, Decl(unknownAfterTypeofEarlyReturn.ts, 0, 51)) +>value : Symbol(value, Decl(unknownAfterTypeofEarlyReturn.ts, 3, 16)) + + if (typeof value === "number") return fromNumber(value); +>value : Symbol(value, Decl(unknownAfterTypeofEarlyReturn.ts, 3, 16)) +>fromNumber : Symbol(fromNumber, Decl(unknownAfterTypeofEarlyReturn.ts, 1, 51)) +>value : Symbol(value, Decl(unknownAfterTypeofEarlyReturn.ts, 3, 16)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/unknownAfterTypeofEarlyReturn.types b/tsc/testdata/baselines/reference/compiler/unknownAfterTypeofEarlyReturn.types new file mode 100644 index 0000000000000..7609eaebb6a66 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/unknownAfterTypeofEarlyReturn.types @@ -0,0 +1,54 @@ +//// [tests/cases/compiler/unknownAfterTypeofEarlyReturn.ts] //// + +=== unknownAfterTypeofEarlyReturn.ts === +declare function fromString(value: string): number; +>fromString : (value: string) => number +>value : string + +declare function fromBigint(value: bigint): number; +>fromBigint : (value: bigint) => number +>value : bigint + +declare function fromNumber(value: number): boolean; +>fromNumber : (value: number) => boolean +>value : number + +function coerce(value: unknown) { +>coerce : (value: unknown) => number | boolean | undefined +>value : unknown + + if (typeof value === "boolean") return value; +>typeof value === "boolean" : boolean +>typeof value : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" +>value : unknown +>"boolean" : "boolean" +>value : boolean + + if (typeof value === "string") return fromString(value); +>typeof value === "string" : boolean +>typeof value : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" +>value : unknown +>"string" : "string" +>fromString(value) : number +>fromString : (value: string) => number +>value : string + + if (typeof value === "bigint") return fromBigint(value); +>typeof value === "bigint" : boolean +>typeof value : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" +>value : unknown +>"bigint" : "bigint" +>fromBigint(value) : number +>fromBigint : (value: bigint) => number +>value : bigint + + if (typeof value === "number") return fromNumber(value); +>typeof value === "number" : boolean +>typeof value : "bigint" | "boolean" | "function" | "number" | "object" | "string" | "symbol" | "undefined" +>value : unknown +>"number" : "number" +>fromNumber(value) : boolean +>fromNumber : (value: number) => boolean +>value : number +} + diff --git a/tsc/testdata/baselines/reference/compiler/webSocketSendArrayBufferLike.errors.txt b/tsc/testdata/baselines/reference/compiler/webSocketSendArrayBufferLike.errors.txt new file mode 100644 index 0000000000000..2f8c553db0fe6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/webSocketSendArrayBufferLike.errors.txt @@ -0,0 +1,19 @@ +webSocketSendArrayBufferLike.ts(3,13): error TS2345: Argument of type 'Uint8Array' is not assignable to parameter of type 'string | Blob | BufferSource'. + Type 'Uint8Array' is not assignable to type 'ArrayBufferView'. + Types of property 'buffer' are incompatible. + Type 'ArrayBufferLike' is not assignable to type 'ArrayBuffer'. + Type 'SharedArrayBuffer' is missing the following properties from type 'ArrayBuffer': resizable, resize, detached, transfer, transferToFixedLength + + +==== webSocketSendArrayBufferLike.ts (1 errors) ==== + declare const socket: WebSocket; + declare const bytes: Uint8Array; + socket.send(bytes); + ~~~~~ +!!! error TS2345: Argument of type 'Uint8Array' is not assignable to parameter of type 'string | Blob | BufferSource'. +!!! error TS2345: Type 'Uint8Array' is not assignable to type 'ArrayBufferView'. +!!! error TS2345: Types of property 'buffer' are incompatible. +!!! error TS2345: Type 'ArrayBufferLike' is not assignable to type 'ArrayBuffer'. +!!! error TS2345: Type 'SharedArrayBuffer' is missing the following properties from type 'ArrayBuffer': resizable, resize, detached, transfer, transferToFixedLength + socket.send(new Uint8Array(8)); + \ No newline at end of file diff --git a/tsc/testdata/baselines/reference/compiler/webSocketSendArrayBufferLike.symbols b/tsc/testdata/baselines/reference/compiler/webSocketSendArrayBufferLike.symbols new file mode 100644 index 0000000000000..0149c657ab078 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/webSocketSendArrayBufferLike.symbols @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/webSocketSendArrayBufferLike.ts] //// + +=== webSocketSendArrayBufferLike.ts === +declare const socket: WebSocket; +>socket : Symbol(socket, Decl(webSocketSendArrayBufferLike.ts, 0, 13)) +>WebSocket : Symbol(WebSocket, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +declare const bytes: Uint8Array; +>bytes : Symbol(bytes, Decl(webSocketSendArrayBufferLike.ts, 1, 13)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) + +socket.send(bytes); +>socket.send : Symbol(WebSocket.send, Decl(lib.dom.d.ts, --, --)) +>socket : Symbol(socket, Decl(webSocketSendArrayBufferLike.ts, 0, 13)) +>send : Symbol(WebSocket.send, Decl(lib.dom.d.ts, --, --)) +>bytes : Symbol(bytes, Decl(webSocketSendArrayBufferLike.ts, 1, 13)) + +socket.send(new Uint8Array(8)); +>socket.send : Symbol(WebSocket.send, Decl(lib.dom.d.ts, --, --)) +>socket : Symbol(socket, Decl(webSocketSendArrayBufferLike.ts, 0, 13)) +>send : Symbol(WebSocket.send, Decl(lib.dom.d.ts, --, --)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 3 more) + diff --git a/tsc/testdata/baselines/reference/compiler/webSocketSendArrayBufferLike.types b/tsc/testdata/baselines/reference/compiler/webSocketSendArrayBufferLike.types new file mode 100644 index 0000000000000..20b70cfd5afe5 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/webSocketSendArrayBufferLike.types @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/webSocketSendArrayBufferLike.ts] //// + +=== webSocketSendArrayBufferLike.ts === +declare const socket: WebSocket; +>socket : WebSocket + +declare const bytes: Uint8Array; +>bytes : Uint8Array + +socket.send(bytes); +>socket.send(bytes) : void +>socket.send : (data: BufferSource | Blob | string) => void +>socket : WebSocket +>send : (data: BufferSource | Blob | string) => void +>bytes : Uint8Array + +socket.send(new Uint8Array(8)); +>socket.send(new Uint8Array(8)) : void +>socket.send : (data: BufferSource | Blob | string) => void +>socket : WebSocket +>send : (data: BufferSource | Blob | string) => void +>new Uint8Array(8) : Uint8Array +>Uint8Array : Uint8ArrayConstructor +>8 : 8 + diff --git a/tsc/testdata/baselines/reference/compiler/workerGlobalMessageHandlerThis.symbols b/tsc/testdata/baselines/reference/compiler/workerGlobalMessageHandlerThis.symbols new file mode 100644 index 0000000000000..f2da0ea9d50b9 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/workerGlobalMessageHandlerThis.symbols @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/workerGlobalMessageHandlerThis.ts] //// + +=== workerGlobalMessageHandlerThis.ts === +declare function createMessageReader(port: MessagePort | Worker | DedicatedWorkerGlobalScope): void; +>createMessageReader : Symbol(createMessageReader, Decl(workerGlobalMessageHandlerThis.ts, 0, 0)) +>port : Symbol(port, Decl(workerGlobalMessageHandlerThis.ts, 0, 37)) +>MessagePort : Symbol(MessagePort, Decl(lib.webworker.d.ts, --, --), Decl(lib.webworker.d.ts, --, --)) +>Worker : Symbol(Worker, Decl(lib.webworker.d.ts, --, --), Decl(lib.webworker.d.ts, --, --)) +>DedicatedWorkerGlobalScope : Symbol(DedicatedWorkerGlobalScope, Decl(lib.webworker.d.ts, --, --), Decl(lib.webworker.d.ts, --, --)) + +createMessageReader(self); +>createMessageReader : Symbol(createMessageReader, Decl(workerGlobalMessageHandlerThis.ts, 0, 0)) +>self : Symbol(self, Decl(lib.webworker.d.ts, --, --)) + +declare const event: MessageEvent; +>event : Symbol(event, Decl(workerGlobalMessageHandlerThis.ts, 3, 13)) +>MessageEvent : Symbol(MessageEvent, Decl(lib.webworker.d.ts, --, --), Decl(lib.webworker.d.ts, --, --), Decl(lib.webworker.d.ts, --, --)) + +self.onmessage?.(event); +>self.onmessage : Symbol(onmessage, Decl(lib.webworker.d.ts, --, --)) +>self : Symbol(self, Decl(lib.webworker.d.ts, --, --)) +>onmessage : Symbol(onmessage, Decl(lib.webworker.d.ts, --, --)) +>event : Symbol(event, Decl(workerGlobalMessageHandlerThis.ts, 3, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/workerGlobalMessageHandlerThis.types b/tsc/testdata/baselines/reference/compiler/workerGlobalMessageHandlerThis.types new file mode 100644 index 0000000000000..e6f994117bc20 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/workerGlobalMessageHandlerThis.types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/workerGlobalMessageHandlerThis.ts] //// + +=== workerGlobalMessageHandlerThis.ts === +declare function createMessageReader(port: MessagePort | Worker | DedicatedWorkerGlobalScope): void; +>createMessageReader : (port: MessagePort | Worker | DedicatedWorkerGlobalScope) => void +>port : DedicatedWorkerGlobalScope | MessagePort | Worker + +createMessageReader(self); +>createMessageReader(self) : void +>createMessageReader : (port: MessagePort | Worker | DedicatedWorkerGlobalScope) => void +>self : WorkerGlobalScope & typeof globalThis + +declare const event: MessageEvent; +>event : MessageEvent + +self.onmessage?.(event); +>self.onmessage?.(event) : any +>self.onmessage : ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any) | null +>self : WorkerGlobalScope & typeof globalThis +>onmessage : ((this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any) | null +>event : MessageEvent + diff --git a/tsc/testdata/baselines/reference/compiler/workerImplementationHandlerThis.symbols b/tsc/testdata/baselines/reference/compiler/workerImplementationHandlerThis.symbols new file mode 100644 index 0000000000000..09e0e6137bca2 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/workerImplementationHandlerThis.symbols @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/workerImplementationHandlerThis.ts] //// + +=== workerImplementationHandlerThis.ts === +declare class WorkerReplacement extends EventTarget implements Worker { +>WorkerReplacement : Symbol(WorkerReplacement, Decl(workerImplementationHandlerThis.ts, 0, 0)) +>EventTarget : Symbol(EventTarget, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>Worker : Symbol(Worker, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + onmessage: ((this: Worker, event: MessageEvent) => any) | null; +>onmessage : Symbol(WorkerReplacement.onmessage, Decl(workerImplementationHandlerThis.ts, 0, 71)) +>this : Symbol(this, Decl(workerImplementationHandlerThis.ts, 1, 17)) +>Worker : Symbol(Worker, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>event : Symbol(event, Decl(workerImplementationHandlerThis.ts, 1, 30)) +>MessageEvent : Symbol(MessageEvent, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + onmessageerror: ((this: Worker, event: MessageEvent) => any) | null; +>onmessageerror : Symbol(WorkerReplacement.onmessageerror, Decl(workerImplementationHandlerThis.ts, 1, 67)) +>this : Symbol(this, Decl(workerImplementationHandlerThis.ts, 2, 22)) +>Worker : Symbol(Worker, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>event : Symbol(event, Decl(workerImplementationHandlerThis.ts, 2, 35)) +>MessageEvent : Symbol(MessageEvent, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + onerror: Worker["onerror"]; +>onerror : Symbol(WorkerReplacement.onerror, Decl(workerImplementationHandlerThis.ts, 2, 72)) +>Worker : Symbol(Worker, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + postMessage: Worker["postMessage"]; +>postMessage : Symbol(WorkerReplacement.postMessage, Decl(workerImplementationHandlerThis.ts, 3, 31)) +>Worker : Symbol(Worker, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + terminate: Worker["terminate"]; +>terminate : Symbol(WorkerReplacement.terminate, Decl(workerImplementationHandlerThis.ts, 4, 39)) +>Worker : Symbol(Worker, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +} + diff --git a/tsc/testdata/baselines/reference/compiler/workerImplementationHandlerThis.types b/tsc/testdata/baselines/reference/compiler/workerImplementationHandlerThis.types new file mode 100644 index 0000000000000..31e8060b820f6 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/workerImplementationHandlerThis.types @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/workerImplementationHandlerThis.ts] //// + +=== workerImplementationHandlerThis.ts === +declare class WorkerReplacement extends EventTarget implements Worker { +>WorkerReplacement : WorkerReplacement +>EventTarget : EventTarget + + onmessage: ((this: Worker, event: MessageEvent) => any) | null; +>onmessage : ((this: Worker, event: MessageEvent) => any) | null +>this : Worker +>event : MessageEvent + + onmessageerror: ((this: Worker, event: MessageEvent) => any) | null; +>onmessageerror : ((this: Worker, event: MessageEvent) => any) | null +>this : Worker +>event : MessageEvent + + onerror: Worker["onerror"]; +>onerror : ((this: AbstractWorker, ev: ErrorEvent) => any) | null + + postMessage: Worker["postMessage"]; +>postMessage : { (message: any, transfer: Transferable[]): void; (message: any, options?: StructuredSerializeOptions): void; } + + terminate: Worker["terminate"]; +>terminate : () => void +} + diff --git a/tsc/testdata/baselines/reference/compiler/workerSubtypeHandlerThis.symbols b/tsc/testdata/baselines/reference/compiler/workerSubtypeHandlerThis.symbols new file mode 100644 index 0000000000000..b4b00ab36925c --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/workerSubtypeHandlerThis.symbols @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/workerSubtypeHandlerThis.ts] //// + +=== workerSubtypeHandlerThis.ts === +interface MockWorker extends Worker { +>MockWorker : Symbol(MockWorker, Decl(workerSubtypeHandlerThis.ts, 0, 0)) +>Worker : Symbol(Worker, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + + messages: unknown[]; +>messages : Symbol(MockWorker.messages, Decl(workerSubtypeHandlerThis.ts, 0, 37)) +} + +declare function forward(worker: Worker): void; +>forward : Symbol(forward, Decl(workerSubtypeHandlerThis.ts, 2, 1)) +>worker : Symbol(worker, Decl(workerSubtypeHandlerThis.ts, 4, 25)) +>Worker : Symbol(Worker, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +declare const worker: MockWorker; +>worker : Symbol(worker, Decl(workerSubtypeHandlerThis.ts, 5, 13)) +>MockWorker : Symbol(MockWorker, Decl(workerSubtypeHandlerThis.ts, 0, 0)) + +forward(worker); +>forward : Symbol(forward, Decl(workerSubtypeHandlerThis.ts, 2, 1)) +>worker : Symbol(worker, Decl(workerSubtypeHandlerThis.ts, 5, 13)) + diff --git a/tsc/testdata/baselines/reference/compiler/workerSubtypeHandlerThis.types b/tsc/testdata/baselines/reference/compiler/workerSubtypeHandlerThis.types new file mode 100644 index 0000000000000..3846cb5022d02 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/workerSubtypeHandlerThis.types @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/workerSubtypeHandlerThis.ts] //// + +=== workerSubtypeHandlerThis.ts === +interface MockWorker extends Worker { + messages: unknown[]; +>messages : unknown[] +} + +declare function forward(worker: Worker): void; +>forward : (worker: Worker) => void +>worker : Worker + +declare const worker: MockWorker; +>worker : MockWorker + +forward(worker); +>forward(worker) : void +>forward : (worker: Worker) => void +>worker : MockWorker + diff --git a/tsc/testdata/baselines/reference/conformance/conditionalExportsRequireDefaultFallback.symbols b/tsc/testdata/baselines/reference/conformance/conditionalExportsRequireDefaultFallback.symbols new file mode 100644 index 0000000000000..0696f4cdbf951 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/conditionalExportsRequireDefaultFallback.symbols @@ -0,0 +1,10 @@ +//// [tests/cases/conformance/moduleResolution/conditionalExportsRequireDefaultFallback.ts] //// + +=== /main.ts === +import { value } from "provider"; +>value : Symbol(value, Decl(main.ts, 0, 8)) + +=== /node_modules/provider/index.d.ts === +export const value: number; +>value : Symbol(value, Decl(index.d.ts, 0, 12)) + diff --git a/tsc/testdata/baselines/reference/conformance/conditionalExportsRequireDefaultFallback.trace.json b/tsc/testdata/baselines/reference/conformance/conditionalExportsRequireDefaultFallback.trace.json new file mode 100644 index 0000000000000..04e445855d68e --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/conditionalExportsRequireDefaultFallback.trace.json @@ -0,0 +1,24 @@ +======== Resolving module 'provider' from '/main.ts'. ======== +Module resolution kind is not specified, using 'Bundler'. +Resolving in CJS mode with conditions 'require', 'types'. +File '/package.json' does not exist. +Loading module 'provider' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. +Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Found 'package.json' at '/node_modules/provider/package.json'. +Entering conditional exports. +Matched 'exports' condition 'require'. +Using 'exports' subpath '.' with target './index.cjs'. +File name '/node_modules/provider/index.cjs' has a '.cjs' extension - stripping it. +File '/node_modules/provider/index.cts' does not exist. +File '/node_modules/provider/index.d.cts' does not exist. +Failed to resolve under condition 'require'. +Matched 'exports' condition 'default'. +Using 'exports' subpath '.' with target './index.js'. +File name '/node_modules/provider/index.js' has a '.js' extension - stripping it. +File '/node_modules/provider/index.ts' does not exist. +File '/node_modules/provider/index.tsx' does not exist. +File '/node_modules/provider/index.d.ts' exists - use it as a name resolution result. +Resolved under condition 'default'. +Exiting conditional exports. +Resolving real path for '/node_modules/provider/index.d.ts', result '/node_modules/provider/index.d.ts'. +======== Module name 'provider' was successfully resolved to '/node_modules/provider/index.d.ts'. ======== diff --git a/tsc/testdata/baselines/reference/conformance/conditionalExportsRequireDefaultFallback.types b/tsc/testdata/baselines/reference/conformance/conditionalExportsRequireDefaultFallback.types new file mode 100644 index 0000000000000..6d3301f2fb030 --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/conditionalExportsRequireDefaultFallback.types @@ -0,0 +1,10 @@ +//// [tests/cases/conformance/moduleResolution/conditionalExportsRequireDefaultFallback.ts] //// + +=== /main.ts === +import { value } from "provider"; +>value : number + +=== /node_modules/provider/index.d.ts === +export const value: number; +>value : number + diff --git a/tsc/testdata/baselines/reference/conformance/conditionalExportsResolutionFallbackNodeNext.trace.json b/tsc/testdata/baselines/reference/conformance/conditionalExportsResolutionFallbackNodeNext.trace.json new file mode 100644 index 0000000000000..e49e2b61f6cab --- /dev/null +++ b/tsc/testdata/baselines/reference/conformance/conditionalExportsResolutionFallbackNodeNext.trace.json @@ -0,0 +1,23 @@ +======== Resolving module 'dep' from '/index.mts'. ======== +Explicitly specified module resolution kind: 'NodeNext'. +Resolving in ESM mode with conditions 'import', 'types', 'node'. +File '/package.json' does not exist. +Loading module 'dep' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON. +Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. +Found 'package.json' at '/node_modules/dep/package.json'. +Entering conditional exports. +Matched 'exports' condition 'import'. +Using 'exports' subpath '.' with target './index.mjs'. +File name '/node_modules/dep/index.mjs' has a '.mjs' extension - stripping it. +File '/node_modules/dep/index.mts' does not exist. +File '/node_modules/dep/index.d.mts' does not exist. +Failed to resolve under condition 'import'. +Saw non-matching condition 'require'. +Matched 'exports' condition 'types'. +Using 'exports' subpath '.' with target './index.d.ts'. +File '/node_modules/dep/index.d.ts' exists - use it as a name resolution result. +'package.json' does not have a 'peerDependencies' field. +Resolved under condition 'types'. +Exiting conditional exports. +Resolving real path for '/node_modules/dep/index.d.ts', result '/node_modules/dep/index.d.ts'. +======== Module name 'dep' was successfully resolved to '/node_modules/dep/index.d.ts' with Package ID 'dep/index.d.ts@1.0.0'. ======== diff --git a/tsc/testdata/baselines/reference/tsc/commandLine/alwaysStrict-false-in-configuration.js b/tsc/testdata/baselines/reference/tsc/commandLine/alwaysStrict-false-in-configuration.js new file mode 100644 index 0000000000000..5bde982f5d622 --- /dev/null +++ b/tsc/testdata/baselines/reference/tsc/commandLine/alwaysStrict-false-in-configuration.js @@ -0,0 +1,43 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/index.ts] *new* +export {}; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{"compilerOptions": {"target": "es2015", "alwaysStrict": false}} + +tsgo --noEmit +ExitStatus:: DiagnosticsPresent_OutputsGenerated +Output:: +tsconfig.json:1:58 - error TS5108: Option 'alwaysStrict=false' has been removed. Please remove it from your configuration. + +1 {"compilerOptions": {"target": "es2015", "alwaysStrict": false}} +   ~~~~~ + + +Found 1 error in tsconfig.json:1 + +//// [/home/src/tslibs/TS/Lib/lib.es6.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; + diff --git a/tsc/testdata/baselines/reference/tsc/commandLine/alwaysStrict-omitted-in-configuration.js b/tsc/testdata/baselines/reference/tsc/commandLine/alwaysStrict-omitted-in-configuration.js new file mode 100644 index 0000000000000..24091a7a513c3 --- /dev/null +++ b/tsc/testdata/baselines/reference/tsc/commandLine/alwaysStrict-omitted-in-configuration.js @@ -0,0 +1,35 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/index.ts] *new* +export {}; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{"compilerOptions": {"target": "es2015"}} + +tsgo --noEmit +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.es6.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; + diff --git a/tsc/testdata/baselines/reference/tsc/commandLine/alwaysStrict-true-in-configuration.js b/tsc/testdata/baselines/reference/tsc/commandLine/alwaysStrict-true-in-configuration.js new file mode 100644 index 0000000000000..eb628f719d4b3 --- /dev/null +++ b/tsc/testdata/baselines/reference/tsc/commandLine/alwaysStrict-true-in-configuration.js @@ -0,0 +1,35 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/index.ts] *new* +export {}; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{"compilerOptions": {"target": "es2015", "alwaysStrict": true}} + +tsgo --noEmit +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.es6.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; + diff --git a/tsc/testdata/baselines/reference/tsc/commandLine/baseUrl-empty-in-configuration.js b/tsc/testdata/baselines/reference/tsc/commandLine/baseUrl-empty-in-configuration.js new file mode 100644 index 0000000000000..f991baa6f927c --- /dev/null +++ b/tsc/testdata/baselines/reference/tsc/commandLine/baseUrl-empty-in-configuration.js @@ -0,0 +1,44 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/index.ts] *new* +export {}; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{"compilerOptions": {"target": "es2015", "baseUrl": ""}} + +tsgo --noEmit +ExitStatus:: DiagnosticsPresent_OutputsGenerated +Output:: +tsconfig.json:1:42 - error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration. + Use '"paths": {"*": ["./*"]}' instead. + +1 {"compilerOptions": {"target": "es2015", "baseUrl": ""}} +   ~~~~~~~~~ + + +Found 1 error in tsconfig.json:1 + +//// [/home/src/tslibs/TS/Lib/lib.es6.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; + diff --git a/tsc/testdata/baselines/reference/tsc/commandLine/baseUrl-inherited-in-configuration.js b/tsc/testdata/baselines/reference/tsc/commandLine/baseUrl-inherited-in-configuration.js new file mode 100644 index 0000000000000..417c0846c9579 --- /dev/null +++ b/tsc/testdata/baselines/reference/tsc/commandLine/baseUrl-inherited-in-configuration.js @@ -0,0 +1,42 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/base.json] *new* +{"compilerOptions": {"target": "es2015", "baseUrl": "."}} +//// [/home/src/workspaces/project/index.ts] *new* +export {}; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{"extends": "./base.json"} + +tsgo --noEmit +ExitStatus:: DiagnosticsPresent_OutputsGenerated +Output:: +error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration. + Use '"paths": {"*": ["./*"]}' instead. + +Found 1 error. + +//// [/home/src/tslibs/TS/Lib/lib.es6.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; + diff --git a/tsc/testdata/baselines/reference/tsc/commandLine/baseUrl-omitted-in-configuration.js b/tsc/testdata/baselines/reference/tsc/commandLine/baseUrl-omitted-in-configuration.js new file mode 100644 index 0000000000000..24091a7a513c3 --- /dev/null +++ b/tsc/testdata/baselines/reference/tsc/commandLine/baseUrl-omitted-in-configuration.js @@ -0,0 +1,35 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/index.ts] *new* +export {}; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{"compilerOptions": {"target": "es2015"}} + +tsgo --noEmit +ExitStatus:: Success +Output:: +//// [/home/src/tslibs/TS/Lib/lib.es6.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; + diff --git a/tsc/testdata/baselines/reference/tsc/commandLine/baseUrl-relative-in-configuration.js b/tsc/testdata/baselines/reference/tsc/commandLine/baseUrl-relative-in-configuration.js new file mode 100644 index 0000000000000..62b45462fc098 --- /dev/null +++ b/tsc/testdata/baselines/reference/tsc/commandLine/baseUrl-relative-in-configuration.js @@ -0,0 +1,44 @@ +currentDirectory::/home/src/workspaces/project +useCaseSensitiveFileNames::true +Input:: +//// [/home/src/workspaces/project/index.ts] *new* +export {}; +//// [/home/src/workspaces/project/tsconfig.json] *new* +{"compilerOptions": {"target": "es2015", "baseUrl": "."}} + +tsgo --noEmit +ExitStatus:: DiagnosticsPresent_OutputsGenerated +Output:: +tsconfig.json:1:42 - error TS5102: Option 'baseUrl' has been removed. Please remove it from your configuration. + Use '"paths": {"*": ["./*"]}' instead. + +1 {"compilerOptions": {"target": "es2015", "baseUrl": "."}} +   ~~~~~~~~~ + + +Found 1 error in tsconfig.json:1 + +//// [/home/src/tslibs/TS/Lib/lib.es6.d.ts] *Lib* +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +interface SymbolConstructor { + (desc?: string | number): symbol; + for(name: string): symbol; + readonly toStringTag: symbol; +} +declare var Symbol: SymbolConstructor; +interface Symbol { + readonly [Symbol.toStringTag]: string; +} +declare const console: { log(msg: any): void; }; + diff --git a/tsc/testdata/tests/cases/compiler/assertedGenericPartialIndexedAssignment.ts b/tsc/testdata/tests/cases/compiler/assertedGenericPartialIndexedAssignment.ts new file mode 100644 index 0000000000000..983e084df3089 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/assertedGenericPartialIndexedAssignment.ts @@ -0,0 +1,7 @@ +// @strict: true +// @target: es2015 +// @noEmit: true + +function write>(values: Partial, key: string) { + (values[key] as unknown) = 0; +} diff --git a/tsc/testdata/tests/cases/compiler/assertedReadonlyParameterPropertyAssignment.ts b/tsc/testdata/tests/cases/compiler/assertedReadonlyParameterPropertyAssignment.ts new file mode 100644 index 0000000000000..3580f347ae678 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/assertedReadonlyParameterPropertyAssignment.ts @@ -0,0 +1,10 @@ +// @strict: true +// @target: es2015 +// @noEmit: true + +class ReadonlyState { + constructor(readonly value: object) {} + clear() { + (this.value as unknown) = null; + } +} diff --git a/tsc/testdata/tests/cases/compiler/callableConstructorUnionMetadata.ts b/tsc/testdata/tests/cases/compiler/callableConstructorUnionMetadata.ts new file mode 100644 index 0000000000000..5e07e809245f3 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/callableConstructorUnionMetadata.ts @@ -0,0 +1,8 @@ +// @strict: true +// @noEmit: true + +type Component = ((props: Props) => number) | (new (props: Props) => object); +type Field = Component & { testIds?: {} }; + +declare const component: (props: Props) => number; +const field: Field = component; diff --git a/tsc/testdata/tests/cases/compiler/callableWeakMetadata.ts b/tsc/testdata/tests/cases/compiler/callableWeakMetadata.ts new file mode 100644 index 0000000000000..3fc8ba4aaeabd --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/callableWeakMetadata.ts @@ -0,0 +1,8 @@ +// @strict: true +// @noEmit: true + +type Initializer = (() => number) & { mutators?: [] }; + +declare function createStore(initializer: Initializer): void; + +createStore(() => 1); diff --git a/tsc/testdata/tests/cases/compiler/callableWeakMetadataCallSuggestion.ts b/tsc/testdata/tests/cases/compiler/callableWeakMetadataCallSuggestion.ts new file mode 100644 index 0000000000000..23ad2e996c278 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/callableWeakMetadataCallSuggestion.ts @@ -0,0 +1,9 @@ +// @strict: true +// @noEmit: true + +type Initializer = (() => number) & { mutators?: [] }; + +declare function createStore(initializer: Initializer): void; +declare const initializer: () => any; + +createStore(initializer); diff --git a/tsc/testdata/tests/cases/compiler/callbackAssignedNonNull.ts b/tsc/testdata/tests/cases/compiler/callbackAssignedNonNull.ts new file mode 100644 index 0000000000000..b5c5b640c222e --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/callbackAssignedNonNull.ts @@ -0,0 +1,12 @@ +// @strict: true +// @noEmit: true + +declare function initialize(callback: (cancel: () => void) => void): void; + +function start() { + let cancel; + initialize(value => { + cancel = value; + }); + cancel!(); +} diff --git a/tsc/testdata/tests/cases/compiler/chainedFilterPredicateInference.ts b/tsc/testdata/tests/cases/compiler/chainedFilterPredicateInference.ts new file mode 100644 index 0000000000000..af002f71550c5 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/chainedFilterPredicateInference.ts @@ -0,0 +1,9 @@ +// @strict: true + +declare const items: { id: number }[]; +declare const registry: { [id: number]: { [frame: number]: unknown } }; + +items + .filter(item => true) + .filter(item => !registry[item.id]) + .forEach(item => item.id); diff --git a/tsc/testdata/tests/cases/compiler/componentEnhancerReturn.ts b/tsc/testdata/tests/cases/compiler/componentEnhancerReturn.ts new file mode 100644 index 0000000000000..58bf1af533a61 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/componentEnhancerReturn.ts @@ -0,0 +1,11 @@ +// @strict: true +// @noEmit: true + +type Component = ((props: number) => number) | (new (props: number) => object); +type App = Component & { getInitialProps?: () => object }; +declare function render(enhance: (app: App) => App): void; +render(app => props => props); + +interface RenderPlugin { enhance(app: Component): (props: number) => number } +declare const plugins: RenderPlugin[]; +render(app => plugins.reduce((result, plugin) => plugin.enhance(result), app)); diff --git a/tsc/testdata/tests/cases/compiler/compoundAssignmentAfterExcludedLiteral.ts b/tsc/testdata/tests/cases/compiler/compoundAssignmentAfterExcludedLiteral.ts new file mode 100644 index 0000000000000..6916fe91344f0 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/compoundAssignmentAfterExcludedLiteral.ts @@ -0,0 +1,7 @@ +// @strict: true + +function append(buffer: { value: string }) { + if (buffer.value !== "") { + buffer.value += "\n"; + } +} diff --git a/tsc/testdata/tests/cases/compiler/conditionalExportsNodeTypesFallback.ts b/tsc/testdata/tests/cases/compiler/conditionalExportsNodeTypesFallback.ts new file mode 100644 index 0000000000000..def40bb08b452 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/conditionalExportsNodeTypesFallback.ts @@ -0,0 +1,22 @@ +// @target: es2015 +// @module: nodenext +// @moduleResolution: nodenext +// @strict: true +// @noEmit: true +// @traceResolution: true +// @noImplicitReferences: true + +// @filename: /node_modules/provider/package.json +{ + "exports": { + "node": "./index.js", + "types": "./types.d.ts" + } +} +// @filename: /node_modules/provider/index.js +exports.value = 0; +// @filename: /node_modules/provider/types.d.ts +export const value: number; +// @filename: /index.mts +import { value } from "provider"; +value; diff --git a/tsc/testdata/tests/cases/compiler/conditionalExportsRequireTypesFallback.ts b/tsc/testdata/tests/cases/compiler/conditionalExportsRequireTypesFallback.ts new file mode 100644 index 0000000000000..28cd35d289928 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/conditionalExportsRequireTypesFallback.ts @@ -0,0 +1,22 @@ +// @target: es2015 +// @module: nodenext +// @moduleResolution: nodenext +// @strict: true +// @noEmit: true +// @traceResolution: true +// @noImplicitReferences: true + +// @filename: /node_modules/provider/package.json +{ + "exports": { + "require": "./index.cjs", + "types": "./index.d.ts" + } +} +// @filename: /node_modules/provider/index.cjs +exports.value = 0; +// @filename: /node_modules/provider/index.d.ts +export const value: number; +// @filename: /index.cts +import { value } from "provider"; +value; diff --git a/tsc/testdata/tests/cases/compiler/conditionalExportsTypesImportFallback.ts b/tsc/testdata/tests/cases/compiler/conditionalExportsTypesImportFallback.ts new file mode 100644 index 0000000000000..70f0e07dd3b92 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/conditionalExportsTypesImportFallback.ts @@ -0,0 +1,26 @@ +// @target: es2015 +// @module: esnext +// @moduleResolution: bundler +// @strict: true +// @noEmit: true +// @traceResolution: true +// @noImplicitReferences: true + +// @filename: /node_modules/theme/package.json +{ + "exports": { + "./tokens": { + "types": "./tokens.d.ts", + "import": "./tokens.mjs", + "default": "./tokens.mjs" + } + } +} +// @filename: /node_modules/theme/tokens.mjs +export default "blue"; +// @filename: /node_modules/theme/tokens.d.mts +declare const color: string; +export default color; +// @filename: /index.mts +import color from "theme/tokens"; +color; diff --git a/tsc/testdata/tests/cases/compiler/conditionalFunctionUnionInference.ts b/tsc/testdata/tests/cases/compiler/conditionalFunctionUnionInference.ts new file mode 100644 index 0000000000000..47a9277a5c0c9 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/conditionalFunctionUnionInference.ts @@ -0,0 +1,11 @@ +// @strict: true +// @target: es2015 +// @noEmit: true + +type DeepValue = T extends () => unknown ? T : + { [K in keyof T]: DeepValue }; + +declare function createValue(initialValue: DeepValue T)>): T; + +const value = createValue(() => ({ ready: true })); +value.ready; diff --git a/tsc/testdata/tests/cases/compiler/conditionalPromptInference.ts b/tsc/testdata/tests/cases/compiler/conditionalPromptInference.ts new file mode 100644 index 0000000000000..04a6b59a10d52 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/conditionalPromptInference.ts @@ -0,0 +1,14 @@ +// @strict: true +// @noEmit: true + +declare function createPrompt( + view: (config: Config, done: (value: Value) => void) => void, +): (config: Config) => Value; + +const numberPrompt = createPrompt(( + config: { required?: Required }, + done: (value: Required extends true ? number : number | undefined) => void, +) => {}); + +const required: number = numberPrompt({ required: true }); +const optional: number | undefined = numberPrompt({ required: false }); diff --git a/tsc/testdata/tests/cases/compiler/contextualFactoryReturnToOptionalClassField.ts b/tsc/testdata/tests/cases/compiler/contextualFactoryReturnToOptionalClassField.ts new file mode 100644 index 0000000000000..3a7a53b801ffb --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/contextualFactoryReturnToOptionalClassField.ts @@ -0,0 +1,11 @@ +// @strict: true +// @target: es2015 +// @lib: es5 +// @noEmit: true + +class Reply { value!: T; } +declare function create unknown, R extends InstanceType>(ctor: Ctor): R; +class Container { + item?: Reply; + initialize() { this.item = create(Reply); } +} diff --git a/tsc/testdata/tests/cases/compiler/contextualGenericReturnToOptionalClassField.ts b/tsc/testdata/tests/cases/compiler/contextualGenericReturnToOptionalClassField.ts new file mode 100644 index 0000000000000..ceb8cc379018d --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/contextualGenericReturnToOptionalClassField.ts @@ -0,0 +1,13 @@ +// @strict: true +// @target: es2015 +// @lib: es5 +// @noEmit: true + +declare function lookup(): T; +class Container { + item?: { label: string }; + getLabel() { + if (!this.item) this.item = lookup(); + return this.item.label; + } +} diff --git a/tsc/testdata/tests/cases/compiler/contextualReturnArrayPatternCallback.ts b/tsc/testdata/tests/cases/compiler/contextualReturnArrayPatternCallback.ts new file mode 100644 index 0000000000000..04519047a9dc7 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/contextualReturnArrayPatternCallback.ts @@ -0,0 +1,19 @@ +// @strict: true + +interface Matcher { + matcher(): { match(value: Input): boolean; value?: Value }; +} +type Pattern = Input | Matcher | { [Key in keyof Input]?: Pattern }; +type ArrayElement = Input extends readonly (infer Value)[] ? Value : unknown; +declare function array>>(value: Value): Matcher; +declare function when unknown>(callback: Callback): Matcher; +declare function accept>(value: Value): void; + +accept({ + list: array({ + prop: when(value => { + const text: string = value; + return true; + }), + }), +}); diff --git a/tsc/testdata/tests/cases/compiler/contextualReturnRecursivePatternArguments.ts b/tsc/testdata/tests/cases/compiler/contextualReturnRecursivePatternArguments.ts new file mode 100644 index 0000000000000..3509850c6573a --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/contextualReturnRecursivePatternArguments.ts @@ -0,0 +1,19 @@ +// @strict: true + +interface Matcher { + matcher(): { match(value: Input): boolean; pattern?: Pattern }; +} +type Pattern = Input | Matcher | { [Key in keyof Input]?: Pattern }; +declare function union, ...Pattern[]]>(...patterns: Patterns): Matcher; +declare function optional>(value: Value): Matcher; +declare function intersection, ...Pattern[]]>(...values: Values): Matcher; +declare function accept>(value: Value): void; + +accept(optional({ + // @ts-expect-error + type: union("oops"), +})); +accept(intersection({ + // @ts-expect-error + type: union("oops"), +})); diff --git a/tsc/testdata/tests/cases/compiler/contextualReturnSpreadPickInference.ts b/tsc/testdata/tests/cases/compiler/contextualReturnSpreadPickInference.ts new file mode 100644 index 0000000000000..3e104e442eb27 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/contextualReturnSpreadPickInference.ts @@ -0,0 +1,16 @@ +// @strict: true +// @target: es2015 +// @noEmit: true + +type Many = T | readonly T[]; +declare function pick( + object: T, + ...props: Many[] +): Pick; + +async function getPage(page: any): Promise<{ title: string; intro: string }> { + return { + title: "", + ...pick(page, ["intro"]), + }; +} diff --git a/tsc/testdata/tests/cases/compiler/contextualRuleMessageInference.ts b/tsc/testdata/tests/cases/compiler/contextualRuleMessageInference.ts new file mode 100644 index 0000000000000..9da85c3e0d57b --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/contextualRuleMessageInference.ts @@ -0,0 +1,15 @@ +// @strict: true +// @noEmit: true + +type DeferredInference = [T][T extends unknown ? 0 : never]; + +declare function runRule( + rule: Message, + tests: { invalid: readonly { errors: readonly { messageId: DeferredInference }[] }[] }, +): void; + +runRule("forbiddenAct", { + invalid: ["act()"].map(() => ({ + errors: [{ messageId: "forbiddenAct" }], + })), +}); diff --git a/tsc/testdata/tests/cases/compiler/correlatedLabelNullishFallback.ts b/tsc/testdata/tests/cases/compiler/correlatedLabelNullishFallback.ts new file mode 100644 index 0000000000000..bdf2d4c085182 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/correlatedLabelNullishFallback.ts @@ -0,0 +1,5 @@ +// @strict: true + +function label(options: { label: string; alias: string } | { label: object; alias?: string }) { + if (typeof options.label === "string") return options.alias ?? options.label; +} diff --git a/tsc/testdata/tests/cases/compiler/cssStyleDeclarationCompatibility.ts b/tsc/testdata/tests/cases/compiler/cssStyleDeclarationCompatibility.ts new file mode 100644 index 0000000000000..8d8f4172bdedf --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/cssStyleDeclarationCompatibility.ts @@ -0,0 +1,8 @@ +// @strict: true +// @target: es2015 +// @lib: es2015, dom, dom.iterable +// @noEmit: true + +declare const element: HTMLElement; +const style: CSSStyleDeclaration = element.style; +[...element.style]; diff --git a/tsc/testdata/tests/cases/compiler/declarationDefaultImportSuggestion.ts b/tsc/testdata/tests/cases/compiler/declarationDefaultImportSuggestion.ts new file mode 100644 index 0000000000000..af1204de45940 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/declarationDefaultImportSuggestion.ts @@ -0,0 +1,10 @@ +// @target: es2015 +// @module: commonjs +// @allowSyntheticDefaultImports: true +// @noEmit: true + +// @filename: store.d.ts +export interface Store {} + +// @filename: main.ts +import Store from "./store"; diff --git a/tsc/testdata/tests/cases/compiler/defaultRootDirExternalFiles.ts b/tsc/testdata/tests/cases/compiler/defaultRootDirExternalFiles.ts new file mode 100644 index 0000000000000..bdc891bdb89ea --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/defaultRootDirExternalFiles.ts @@ -0,0 +1,12 @@ +// @currentDirectory: /project + +// @filename: /project/example/tsconfig.json +{ + "compilerOptions": { + "outDir": "." + }, + "files": ["../src/index.ts"] +} + +// @filename: /project/src/index.ts +export const value = 0; diff --git a/tsc/testdata/tests/cases/compiler/defaultRootDirInheritedInclude.ts b/tsc/testdata/tests/cases/compiler/defaultRootDirInheritedInclude.ts new file mode 100644 index 0000000000000..2958320765709 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/defaultRootDirInheritedInclude.ts @@ -0,0 +1,17 @@ +// @currentDirectory: /project + +// @filename: /project/example/tsconfig.json +{ + "extends": "../tsconfig.json" +} + +// @filename: /project/tsconfig.json +{ + "compilerOptions": { + "outDir": "lib" + }, + "include": ["src"] +} + +// @filename: /project/src/index.ts +export const value = 0; diff --git a/tsc/testdata/tests/cases/compiler/defaultTypesExcludeAmbientModuleImports.ts b/tsc/testdata/tests/cases/compiler/defaultTypesExcludeAmbientModuleImports.ts new file mode 100644 index 0000000000000..459c6a6c7e5a7 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/defaultTypesExcludeAmbientModuleImports.ts @@ -0,0 +1,14 @@ +// @module: nodenext +// @noEmit: true +// @noImplicitReferences: true +// @currentDirectory: / + +// @filename: /node_modules/@types/runtime/index.d.ts +declare module "engine" { + export const value: number; + export default function read(): void; +} + +// @filename: /main.mts +import { value } from "engine"; +export { default as engine } from "engine"; diff --git a/tsc/testdata/tests/cases/compiler/defaultTypesExcludeAmbientPackages.ts b/tsc/testdata/tests/cases/compiler/defaultTypesExcludeAmbientPackages.ts new file mode 100644 index 0000000000000..ddfc4e3d48633 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/defaultTypesExcludeAmbientPackages.ts @@ -0,0 +1,11 @@ +// @target: es2015 +// @strict: true +// @noEmit: true +// @noImplicitReferences: true +// @currentDirectory: / + +// @filename: /node_modules/@types/runtime/index.d.ts +declare const __dirname: string; + +// @filename: /main.ts +__dirname; diff --git a/tsc/testdata/tests/cases/compiler/defaultTypesExcludeBaseLibraryReferences.ts b/tsc/testdata/tests/cases/compiler/defaultTypesExcludeBaseLibraryReferences.ts new file mode 100644 index 0000000000000..08da07c65aaa2 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/defaultTypesExcludeBaseLibraryReferences.ts @@ -0,0 +1,13 @@ +// @target: es2015 +// @lib: es2021.weakref +// @module: commonjs +// @strict: true +// @skipLibCheck: true +// @noEmit: true +// @noImplicitReferences: true + +// @filename: /node_modules/@types/runtime/index.d.ts +/// + +// @filename: /main.ts +export {}; diff --git a/tsc/testdata/tests/cases/compiler/defaultTypesExcludeLibraryReferences.ts b/tsc/testdata/tests/cases/compiler/defaultTypesExcludeLibraryReferences.ts new file mode 100644 index 0000000000000..e0d3d6ff97427 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/defaultTypesExcludeLibraryReferences.ts @@ -0,0 +1,9 @@ +// @target: es2015 +// @noEmit: true +// @noImplicitReferences: true + +// @filename: /node_modules/@types/runtime/index.d.ts +/// + +// @filename: /main.ts +["workflow.yml"].includes("workflow.yml"); diff --git a/tsc/testdata/tests/cases/compiler/defaultWeakMapInferredPropertyAssignment.ts b/tsc/testdata/tests/cases/compiler/defaultWeakMapInferredPropertyAssignment.ts new file mode 100644 index 0000000000000..f4d6f46179395 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/defaultWeakMapInferredPropertyAssignment.ts @@ -0,0 +1,5 @@ +// @target: esnext +// @lib: es2023 +// @strict: true +const frameInfo = { frames: new WeakMap() }; +const target: { frames: WeakMap<{ id: string }, number> } = frameInfo; diff --git a/tsc/testdata/tests/cases/compiler/distributedRecursiveMappedType.ts b/tsc/testdata/tests/cases/compiler/distributedRecursiveMappedType.ts new file mode 100644 index 0000000000000..a3084046746be --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/distributedRecursiveMappedType.ts @@ -0,0 +1,5 @@ +// @noEmit: true + +type Exact = Shape extends Shape + ? { [Key in keyof Shape]: Exact } + : never; diff --git a/tsc/testdata/tests/cases/compiler/domBaseElementToSpan.ts b/tsc/testdata/tests/cases/compiler/domBaseElementToSpan.ts new file mode 100644 index 0000000000000..2e712e407db5d --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/domBaseElementToSpan.ts @@ -0,0 +1,5 @@ +// @target: es2015 +// @strict: true + +declare const element: HTMLElement; +const span: HTMLSpanElement = element; diff --git a/tsc/testdata/tests/cases/compiler/domDirectoryReaderArrayCallbacks.ts b/tsc/testdata/tests/cases/compiler/domDirectoryReaderArrayCallbacks.ts new file mode 100644 index 0000000000000..73314c28a62bd --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/domDirectoryReaderArrayCallbacks.ts @@ -0,0 +1,8 @@ +// @strict: true +// @target: es2015 +// @lib: es2015,dom + +declare const reader: FileSystemDirectoryReader; +reader.readEntries(entries => entries.length); +reader.readEntries(async (entries: FileSystemEntry[]) => {}); +new Promise(resolve => reader.readEntries(resolve)); diff --git a/tsc/testdata/tests/cases/compiler/domElementStringKeyConstraint.ts b/tsc/testdata/tests/cases/compiler/domElementStringKeyConstraint.ts new file mode 100644 index 0000000000000..76506fc8f7177 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/domElementStringKeyConstraint.ts @@ -0,0 +1,7 @@ +// @target: es2015 +// @strict: true + +declare function setProperty(element: T, property: K, value: T[K]): void; +declare const element: Element; +declare const key: keyof Element; +setProperty(element, key, true); diff --git a/tsc/testdata/tests/cases/compiler/domIterableGenericDatasetKeys.ts b/tsc/testdata/tests/cases/compiler/domIterableGenericDatasetKeys.ts new file mode 100644 index 0000000000000..ee360d17f35fb --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/domIterableGenericDatasetKeys.ts @@ -0,0 +1,8 @@ +// @strict: true +// @target: es2015 +// @lib: esnext, dom + +function restore(key: Key, element: HTMLElement) { + const value = element.dataset[key]; + delete element.dataset[key]; +} diff --git a/tsc/testdata/tests/cases/compiler/domIterableSymbolMappedValue.ts b/tsc/testdata/tests/cases/compiler/domIterableSymbolMappedValue.ts new file mode 100644 index 0000000000000..a4c9a4628804f --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/domIterableSymbolMappedValue.ts @@ -0,0 +1,7 @@ +// @strict: true +// @target: es2015 +// @lib: esnext, dom + +declare const styles: Partial>; +declare function element(styles: Partial>): void; +element(styles); diff --git a/tsc/testdata/tests/cases/compiler/domObserverArrayCallbacks.ts b/tsc/testdata/tests/cases/compiler/domObserverArrayCallbacks.ts new file mode 100644 index 0000000000000..706f124c5fd0c --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/domObserverArrayCallbacks.ts @@ -0,0 +1,7 @@ +// @strict: true +// @target: es2015 +// @lib: es2015,dom + +new ResizeObserver(entries => entries[0]); +new MutationObserver(records => records.some(record => record.attributeName === "style")); +new IntersectionObserver(entries => entries.forEach(entry => entry.isIntersecting)); diff --git a/tsc/testdata/tests/cases/compiler/domResizeObserverExplicitArrayCallback.ts b/tsc/testdata/tests/cases/compiler/domResizeObserverExplicitArrayCallback.ts new file mode 100644 index 0000000000000..3002c4fbf1c6f --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/domResizeObserverExplicitArrayCallback.ts @@ -0,0 +1,5 @@ +// @strict: true +// @target: es2015 +// @lib: es2015,dom + +new ResizeObserver((entries: ResizeObserverEntry[]) => {}); diff --git a/tsc/testdata/tests/cases/compiler/domTreeWalkerStructuralMock.ts b/tsc/testdata/tests/cases/compiler/domTreeWalkerStructuralMock.ts new file mode 100644 index 0000000000000..7d756addece32 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/domTreeWalkerStructuralMock.ts @@ -0,0 +1,19 @@ +// @target: es2015 +// @strict: true + +declare class Walker implements TreeWalker { + currentNode: Node; + readonly filter: NodeFilter | null; + readonly root: Node; + readonly whatToShow: number; + firstChild(): Node | null; + lastChild(): Node | null; + nextNode(): Node | null; + nextSibling(): Node | null; + parentNode(): Node | null; + previousNode(): Node | null; + previousSibling(): Node | null; +} + +declare const walker: Walker; +const result: TreeWalker = walker; diff --git a/tsc/testdata/tests/cases/compiler/dynamicDeclarationDefault.ts b/tsc/testdata/tests/cases/compiler/dynamicDeclarationDefault.ts new file mode 100644 index 0000000000000..4db5af5428621 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/dynamicDeclarationDefault.ts @@ -0,0 +1,13 @@ +// @target: es2024 +// @module: nodenext +// @strict: true +// @esModuleInterop: true + +// @filename: profiler.d.ts +declare module "profiler" { + export function start(): void; +} + +// @filename: main.mts +const { default: profiler } = await import("profiler"); +profiler.start(); diff --git a/tsc/testdata/tests/cases/compiler/embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts b/tsc/testdata/tests/cases/compiler/embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts new file mode 100644 index 0000000000000..00560737a2fb9 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/embeddedNumericCompoundAssignmentAfterExcludedLiterals.ts @@ -0,0 +1,8 @@ +// @strict: true + +function ease(value: number, divisor: number) { + if (value === 0) return 0; + value /= divisor; + if (value === 2) return 2; + return Math.pow(2, -10 * (value -= 1)); +} diff --git a/tsc/testdata/tests/cases/compiler/emptyMappedJsxProps.tsx b/tsc/testdata/tests/cases/compiler/emptyMappedJsxProps.tsx new file mode 100644 index 0000000000000..3f65298810159 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/emptyMappedJsxProps.tsx @@ -0,0 +1,15 @@ +// @strict: true +// @jsx: preserve +// @noEmit: true + +declare namespace JSX { + interface Element {} + interface ElementAttributesProperty { props: {}; } + interface ElementChildrenAttribute { children: {}; } + interface IntrinsicAttributes { key?: string; } +} + +class Component { + props: Readonly<{}> = {}; +} +content; diff --git a/tsc/testdata/tests/cases/compiler/emptyMappedParserMetadata.ts b/tsc/testdata/tests/cases/compiler/emptyMappedParserMetadata.ts new file mode 100644 index 0000000000000..7129991ce7483 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/emptyMappedParserMetadata.ts @@ -0,0 +1,8 @@ +// @strict: true +// @noEmit: true + +type ParserName = "babel" | (Pick & { marker?: never }); + +declare const customParser: string; +const parser: ParserName = customParser; +const svelteParser: ParserName = "svelte"; diff --git a/tsc/testdata/tests/cases/compiler/enumPropertyExhaustiveNullableReceiver.ts b/tsc/testdata/tests/cases/compiler/enumPropertyExhaustiveNullableReceiver.ts new file mode 100644 index 0000000000000..87ccc45e7af83 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/enumPropertyExhaustiveNullableReceiver.ts @@ -0,0 +1,15 @@ +// @strict: true +// @target: es2015 + +enum NotificationKind { Review, Comment } + +declare function assertNever(value: never): never; + +function notify(notification: { kind: NotificationKind } | null) { + if (notification === null) return; + switch (notification.kind) { + case NotificationKind.Review: return; + case NotificationKind.Comment: return; + default: return assertNever(notification.kind); + } +} diff --git a/tsc/testdata/tests/cases/compiler/excludedNumericLiteralAfterDecrement.ts b/tsc/testdata/tests/cases/compiler/excludedNumericLiteralAfterDecrement.ts new file mode 100644 index 0000000000000..f2a0f7f09a4ef --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/excludedNumericLiteralAfterDecrement.ts @@ -0,0 +1,7 @@ +// @strict: true + +function decrement(count: number) { + if (count === 0) return; + count--; + if (count === 0) return; +} diff --git a/tsc/testdata/tests/cases/compiler/fetchContextualRequestUrl.ts b/tsc/testdata/tests/cases/compiler/fetchContextualRequestUrl.ts new file mode 100644 index 0000000000000..1bdd5e3937024 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/fetchContextualRequestUrl.ts @@ -0,0 +1,8 @@ +// @strict: true +// @lib: es2015,dom +// @noEmit: true + +const fetchUsingRequestUrl: typeof fetch = async input => { + const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url; + return new Response(url); +}; diff --git a/tsc/testdata/tests/cases/compiler/fetchOverloadCallableCopy.ts b/tsc/testdata/tests/cases/compiler/fetchOverloadCallableCopy.ts new file mode 100644 index 0000000000000..68258e8ce4aa0 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/fetchOverloadCallableCopy.ts @@ -0,0 +1,8 @@ +// @strict: true +// @lib: es2015,dom +// @noEmit: true + +declare function fetch(input: RequestInfo | URL, init?: RequestInit): Promise; +type CallableCopy unknown> = (...args: Parameters) => ReturnType; +declare const copiedFetch: CallableCopy; +const replacementFetch: typeof fetch = copiedFetch; diff --git a/tsc/testdata/tests/cases/compiler/fetchReplacementInputCompatibility.ts b/tsc/testdata/tests/cases/compiler/fetchReplacementInputCompatibility.ts new file mode 100644 index 0000000000000..2a8eced90d7c0 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/fetchReplacementInputCompatibility.ts @@ -0,0 +1,9 @@ +// @strict: true +// @lib: es2015,dom +// @noEmit: true + +declare const fetchReplacement: (input: string | URL | Request, init?: RequestInit) => Promise; +const replacement: typeof fetch = fetchReplacement; + +declare const input: Parameters[0]; +fetchReplacement(input); diff --git a/tsc/testdata/tests/cases/compiler/genericCallInNegativeTypeofBranch.ts b/tsc/testdata/tests/cases/compiler/genericCallInNegativeTypeofBranch.ts new file mode 100644 index 0000000000000..45681db2f3134 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/genericCallInNegativeTypeofBranch.ts @@ -0,0 +1,6 @@ +// @strict: true + +declare function identity(value: T): T; +function normalize(value: unknown) { + return typeof value === "string" ? value : identity(value); +} diff --git a/tsc/testdata/tests/cases/compiler/genericContextualComposition.ts b/tsc/testdata/tests/cases/compiler/genericContextualComposition.ts new file mode 100644 index 0000000000000..dd879a4665c84 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/genericContextualComposition.ts @@ -0,0 +1,7 @@ +// @strict: true + +type Enhancer = (next: Next) => Next & Extension; +declare function compose(first: (value: A) => Result, second: (...args: Args) => A): (...args: Args) => Result; +declare function compose(...functions: Function[]): (...args: any[]) => Result; +declare const instrument: Enhancer<{ extra: unknown }>, persist: Enhancer; +const enhancer: Enhancer = compose(instrument, persist); diff --git a/tsc/testdata/tests/cases/compiler/genericValueMarker.ts b/tsc/testdata/tests/cases/compiler/genericValueMarker.ts new file mode 100644 index 0000000000000..83f21e77888ae --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/genericValueMarker.ts @@ -0,0 +1,7 @@ +// @strict: true +// @noEmit: true + +declare const valueMarker: unique symbol; +type AnyValue = { [valueMarker]?: undefined } | number; +declare function compare(value: Value & AnyValue): void; +compare((): number => 0); diff --git a/tsc/testdata/tests/cases/compiler/identityOfInstantiatedMappedIntersection.ts b/tsc/testdata/tests/cases/compiler/identityOfInstantiatedMappedIntersection.ts new file mode 100644 index 0000000000000..6c4f75b4cfeb0 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/identityOfInstantiatedMappedIntersection.ts @@ -0,0 +1,8 @@ +// @strict: true +declare const brand: unique symbol; +type Equal = (() => V extends T ? 1 : 2) extends (() => V extends U ? 1 : 2) ? true : false; +declare function assertEqual(value: Equal): void; + +type Flatten = { [K in keyof T]: T[K] }; +type Branded = Flatten<{ name: string }> & { [brand]: { label: true } }; +assertEqual(true); diff --git a/tsc/testdata/tests/cases/compiler/indexedAnyPredicateInForLoop.ts b/tsc/testdata/tests/cases/compiler/indexedAnyPredicateInForLoop.ts new file mode 100644 index 0000000000000..6b48db8b70fb8 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/indexedAnyPredicateInForLoop.ts @@ -0,0 +1,11 @@ +// @target: es2015 +// @strict: true +declare function isPrimitive(value: any): value is string | number; +declare function createText(text: string | undefined): object; +function normalize(children: any) { + for (let index = 0; index < children.length; ++index) { + if (isPrimitive(children[index])) { + children[index] = createText(children[index]); + } + } +} diff --git a/tsc/testdata/tests/cases/compiler/inheritedOutputDirectoryRoot.ts b/tsc/testdata/tests/cases/compiler/inheritedOutputDirectoryRoot.ts new file mode 100644 index 0000000000000..ed0a778fdfaee --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/inheritedOutputDirectoryRoot.ts @@ -0,0 +1,12 @@ +// @target: es2015 +// @noImplicitReferences: true +// @fullEmitPaths: true + +// @filename: /project/base.json +{ "compilerOptions": { "outDir": "dist" } } + +// @filename: /project/src/index.ts +export const value = 0; + +// @filename: /project/tsconfig.json +{ "extends": "./base.json", "compilerOptions": {}, "files": ["src/index.ts"] } diff --git a/tsc/testdata/tests/cases/compiler/iteratorResultNullishValueAssignment.ts b/tsc/testdata/tests/cases/compiler/iteratorResultNullishValueAssignment.ts new file mode 100644 index 0000000000000..58f483f084149 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/iteratorResultNullishValueAssignment.ts @@ -0,0 +1,8 @@ +// @strict: true +// @target: es2015 + +function initialize(result: IteratorResult) { + if (result.value == null) { + result.value = {}; + } +} diff --git a/tsc/testdata/tests/cases/compiler/jsxChildrenExcessPropertySuppression.tsx b/tsc/testdata/tests/cases/compiler/jsxChildrenExcessPropertySuppression.tsx new file mode 100644 index 0000000000000..120bf9bcdea51 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/jsxChildrenExcessPropertySuppression.tsx @@ -0,0 +1,13 @@ +// @target: es2022 +// @jsx: preserve +// @strict: true +declare namespace JSX { + interface Element {} + interface ElementChildrenAttribute { children: {}; } +} +declare function Item(props: { depth: number }): JSX.Element; +// @ts-ignore +text; diff --git a/tsc/testdata/tests/cases/compiler/largeDiscriminantUnionArrayPredicate.ts b/tsc/testdata/tests/cases/compiler/largeDiscriminantUnionArrayPredicate.ts new file mode 100644 index 0000000000000..cbc0d6eaece2b --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/largeDiscriminantUnionArrayPredicate.ts @@ -0,0 +1,19 @@ +// @strict: true + +type TreeNode = + | { kind: 0 } + | { kind: 1 } + | { kind: 2 } + | { kind: 3 } + | { kind: 4 } + | { kind: 5 } + | { kind: 6 } + | { kind: 7 } + | { kind: 8 } + | { kind: 9 }; + +declare const ancestor: TreeNode | TreeNode[]; + +if (!Array.isArray(ancestor)) { + ancestor.kind; +} diff --git a/tsc/testdata/tests/cases/compiler/literalUnionAfterExcludedComparisons.ts b/tsc/testdata/tests/cases/compiler/literalUnionAfterExcludedComparisons.ts new file mode 100644 index 0000000000000..b10fc2d2f020a --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/literalUnionAfterExcludedComparisons.ts @@ -0,0 +1,10 @@ +// @target: es2021 +// @strict: true + +type Runtime = "node" | "deno" | "bun"; +function readRuntime(value: string): Runtime { + if (value !== "node" && value !== "deno" && value !== "bun") { + throw new Error(); + } + return value; +} diff --git a/tsc/testdata/tests/cases/compiler/logicalNotUndefinedComparison.ts b/tsc/testdata/tests/cases/compiler/logicalNotUndefinedComparison.ts new file mode 100644 index 0000000000000..f63b3e95c5a91 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/logicalNotUndefinedComparison.ts @@ -0,0 +1,6 @@ +// @strict: true +// @target: es2015 + +function isNode(object: { type?: string }) { + return !object.type !== undefined; +} diff --git a/tsc/testdata/tests/cases/compiler/loopArrayLengthInferenceCycle.ts b/tsc/testdata/tests/cases/compiler/loopArrayLengthInferenceCycle.ts new file mode 100644 index 0000000000000..e444487b2a784 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/loopArrayLengthInferenceCycle.ts @@ -0,0 +1,18 @@ +// @strict: true + +function tokenize() { + let state: { matches: string[]; groups: string[][] } | null = null; + while (true) { + let matches: string[] | null = null; + let action: string[] | null = null; + if (state) { + const groupEntry = state.groups[0]; + action = groupEntry; + } + matches = []; + if (action) { + if (matches.length !== action.length) throw new Error(); + state = { matches, groups: [] }; + } + } +} diff --git a/tsc/testdata/tests/cases/compiler/messagePortHandlerEventTypes.ts b/tsc/testdata/tests/cases/compiler/messagePortHandlerEventTypes.ts new file mode 100644 index 0000000000000..f2c829805f29b --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/messagePortHandlerEventTypes.ts @@ -0,0 +1,11 @@ +// @strict: true +// @lib: es5,dom +// @noEmit: true + +declare const port: MessagePort; +port.onmessage = event => { + event.data; +}; +port.onmessageerror = event => { + event.data; +}; diff --git a/tsc/testdata/tests/cases/compiler/missingTypesConditionDefaultSidecar.ts b/tsc/testdata/tests/cases/compiler/missingTypesConditionDefaultSidecar.ts new file mode 100644 index 0000000000000..479823ae1b74d --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/missingTypesConditionDefaultSidecar.ts @@ -0,0 +1,22 @@ +// @module: esnext +// @moduleResolution: bundler +// @strict: true +// @traceResolution: true +// @noEmit: true + +// @filename: node_modules/font/package.json +{ + "exports": { + "./sans": { + "types": "./missing.d.ts", + "default": "./sans.js" + } + } +} + +// @filename: node_modules/font/sans.d.ts +export const font: { className: string }; + +// @filename: main.ts +import { font } from "font/sans"; +font.className; diff --git a/tsc/testdata/tests/cases/compiler/moduleKeywordInstantiatedNamespace.ts b/tsc/testdata/tests/cases/compiler/moduleKeywordInstantiatedNamespace.ts new file mode 100644 index 0000000000000..a9806e7addf59 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/moduleKeywordInstantiatedNamespace.ts @@ -0,0 +1,7 @@ +// @target: es2015 +// @noEmit: true + +module Runtime { + export const value = 0; +} +Runtime.value; diff --git a/tsc/testdata/tests/cases/compiler/namespaceFunctionReservedDefaultParameter.ts b/tsc/testdata/tests/cases/compiler/namespaceFunctionReservedDefaultParameter.ts new file mode 100644 index 0000000000000..ae8c8fd03b058 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/namespaceFunctionReservedDefaultParameter.ts @@ -0,0 +1,10 @@ +// @target: es2015 + +namespace Dependencies { + export function scripts(static = false) { + if (static) { + return "static.js"; + } + return "interactive.js"; + } +} diff --git a/tsc/testdata/tests/cases/compiler/newTargetUndefinedEquality.ts b/tsc/testdata/tests/cases/compiler/newTargetUndefinedEquality.ts new file mode 100644 index 0000000000000..9cda8dc74831d --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/newTargetUndefinedEquality.ts @@ -0,0 +1,8 @@ +// @strict: true +// @target: es2015 + +class ConstructorGuard { + constructor() { + if (new.target === undefined) throw TypeError("Constructor requires new"); + } +} diff --git a/tsc/testdata/tests/cases/compiler/nonStrictOptionalNeverResult.ts b/tsc/testdata/tests/cases/compiler/nonStrictOptionalNeverResult.ts new file mode 100644 index 0000000000000..cf7f2c7951569 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/nonStrictOptionalNeverResult.ts @@ -0,0 +1,7 @@ +// @strict: false + +type Result = { error: string; details?: never } | { details: { link: string }; error?: never }; +function read(result: Result) { + if (result.error || !result.details) return; + return result.details.link; +} diff --git a/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentAfterBreak.ts b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentAfterBreak.ts new file mode 100644 index 0000000000000..7ea4a2c1c0077 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentAfterBreak.ts @@ -0,0 +1,7 @@ +// @strict: true +function drain(count: number) { + for (;;) { + if (count === 0) break; + count -= 1; + } +} diff --git a/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentAfterContinue.ts b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentAfterContinue.ts new file mode 100644 index 0000000000000..972949d796081 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentAfterContinue.ts @@ -0,0 +1,7 @@ +// @strict: true +function consume(count: number) { + for (;;) { + if (count === 0) continue; + count -= 1; + } +} diff --git a/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentAfterExcludedZero.ts b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentAfterExcludedZero.ts new file mode 100644 index 0000000000000..8fe28f3cb5c6f --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentAfterExcludedZero.ts @@ -0,0 +1,6 @@ +// @strict: true + +function divide(value: number, divisor: number) { + if (value === 0) return; + value /= divisor; +} diff --git a/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentInCallback.ts b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentInCallback.ts new file mode 100644 index 0000000000000..b2228e6c16db8 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentInCallback.ts @@ -0,0 +1,7 @@ +// @strict: true +function createConsumer(count: number) { + return () => { + if (count === 0) return; + count -= 1; + }; +} diff --git a/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentInElseBranch.ts b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentInElseBranch.ts new file mode 100644 index 0000000000000..b10fc71e686d1 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentInElseBranch.ts @@ -0,0 +1,8 @@ +// @strict: true +function accumulate(total: number, width: number, kernedWidth: number) { + if (total === 0) { + total += width; + } else { + total += kernedWidth; + } +} diff --git a/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentInForUpdateAfterExcludedZero.ts b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentInForUpdateAfterExcludedZero.ts new file mode 100644 index 0000000000000..114e5cd984f3a --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentInForUpdateAfterExcludedZero.ts @@ -0,0 +1,4 @@ +// @strict: true +function shift(bitmap: number) { + for (let index = 0; bitmap !== 0; index++, bitmap >>>= 1) {} +} diff --git a/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentInWhileLoopAfterExcludedZero.ts b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentInWhileLoopAfterExcludedZero.ts new file mode 100644 index 0000000000000..3b49f9fc55d7e --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentInWhileLoopAfterExcludedZero.ts @@ -0,0 +1,6 @@ +// @strict: true +function rewind(index: number) { + while (index !== 0) { + index -= 1; + } +} diff --git a/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentsAfterConjunction.ts b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentsAfterConjunction.ts new file mode 100644 index 0000000000000..fbe588209cb85 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentsAfterConjunction.ts @@ -0,0 +1,11 @@ +// @strict: true +function scale(left: number, right: number) { + if (left !== 0 && right !== 0) { + left *= -1.5; + right *= -1.5; + } else if (left !== 0) { + left *= -2; + } else if (right !== 0) { + right *= -2; + } +} diff --git a/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentsInNonzeroBranch.ts b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentsInNonzeroBranch.ts new file mode 100644 index 0000000000000..f4a203b45dbe0 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/numericCompoundAssignmentsInNonzeroBranch.ts @@ -0,0 +1,7 @@ +// @strict: true +function scale(value: number, factor: number) { + if (value !== 0) { + value *= -1; + value *= factor; + } +} diff --git a/tsc/testdata/tests/cases/compiler/numericPropertyCompoundAssignmentAfterDisjunction.ts b/tsc/testdata/tests/cases/compiler/numericPropertyCompoundAssignmentAfterDisjunction.ts new file mode 100644 index 0000000000000..11b38a4226bbe --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/numericPropertyCompoundAssignmentAfterDisjunction.ts @@ -0,0 +1,8 @@ +// @strict: true +class Decoder { + remaining = 0; + consume(size: number) { + if (this.remaining === 0 || size === 0) return; + this.remaining -= size; + } +} diff --git a/tsc/testdata/tests/cases/compiler/objectEntriesGenericMappedValues.ts b/tsc/testdata/tests/cases/compiler/objectEntriesGenericMappedValues.ts new file mode 100644 index 0000000000000..c22b814feabbe --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/objectEntriesGenericMappedValues.ts @@ -0,0 +1,8 @@ +// @strict: true +// @target: es2017 + +function read(attributes: Partial) { + const [, value] = Object.entries(attributes)[0]; + Object.entries(value); + const tabIndex: number = value; +} diff --git a/tsc/testdata/tests/cases/compiler/objectEntriesMapBroadKeyLookup.ts b/tsc/testdata/tests/cases/compiler/objectEntriesMapBroadKeyLookup.ts new file mode 100644 index 0000000000000..8276d8e35f425 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/objectEntriesMapBroadKeyLookup.ts @@ -0,0 +1,7 @@ +// @target: es2017 +// @strict: true + +declare const languages: Record<"en" | "fr", string>; +declare const language: string; + +new Map(Object.entries(languages)).get(language); diff --git a/tsc/testdata/tests/cases/compiler/objectEntriesObjectArrayNarrowing.ts b/tsc/testdata/tests/cases/compiler/objectEntriesObjectArrayNarrowing.ts new file mode 100644 index 0000000000000..77200f4a07b7c --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/objectEntriesObjectArrayNarrowing.ts @@ -0,0 +1,9 @@ +// @target: es2017 +// @strict: true + +declare const record: object; +for (const [, value] of Object.entries(record)) { + if (Array.isArray(value)) { + value.forEach(() => {}); + } +} diff --git a/tsc/testdata/tests/cases/compiler/objectEntriesPartialIndexedWrite.ts b/tsc/testdata/tests/cases/compiler/objectEntriesPartialIndexedWrite.ts new file mode 100644 index 0000000000000..3d3f54f4c255c --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/objectEntriesPartialIndexedWrite.ts @@ -0,0 +1,11 @@ +// @target: es2022 +// @strict: false + +type Row = { amount: number } & Record; +export function copy(row: Row, mapping: { amount: string; notes: string }) { + const result: Partial = {}; + for (const [field, target] of Object.entries(mapping)) { + result[field] = row[target]; + } + return result; +} diff --git a/tsc/testdata/tests/cases/compiler/objectEntriesSymbolValueArity.ts b/tsc/testdata/tests/cases/compiler/objectEntriesSymbolValueArity.ts new file mode 100644 index 0000000000000..8992e3e899ccd --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/objectEntriesSymbolValueArity.ts @@ -0,0 +1,12 @@ +// @strict: true +// @target: es2017 + +declare const database: unique symbol; +declare const models: { + user: { create(entity?: object): void }; + [database]: { create(name: string, entity: object, id?: string): void }; +}; + +for (const [, model] of Object.entries(models)) { + model.create({}); +} diff --git a/tsc/testdata/tests/cases/compiler/objectFromEntriesAdditionalProperty.ts b/tsc/testdata/tests/cases/compiler/objectFromEntriesAdditionalProperty.ts new file mode 100644 index 0000000000000..35363370d248e --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/objectFromEntriesAdditionalProperty.ts @@ -0,0 +1,6 @@ +// @target: es2019 +// @strict: true + +declare const keys: ("language" | "theme")[]; +const settings = Object.fromEntries(keys.map(key => [key, ""])); +settings.timestamp = ""; diff --git a/tsc/testdata/tests/cases/compiler/objectFromEntriesBrandedTemplateKeys.ts b/tsc/testdata/tests/cases/compiler/objectFromEntriesBrandedTemplateKeys.ts new file mode 100644 index 0000000000000..b933e19b43053 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/objectFromEntriesBrandedTemplateKeys.ts @@ -0,0 +1,15 @@ +// @target: es2019 +// @strict: true + +type FeatureId = string & { feature: true }; +declare const featureIds: FeatureId[]; +const options = Object.fromEntries(featureIds.map(id => [`feature:${id}`, true])); +declare const featureName: string; + +options[`feature:${featureName}`]; +featureIds.filter(id => options["feature:" + id]); +for (const [from, to] of Object.entries({ oldFeature: "newFeature" })) { + if (typeof options[`feature:${from}`] === "boolean") { + options[`feature:${to}`] = options[`feature:${from}`]; + } +} diff --git a/tsc/testdata/tests/cases/compiler/objectFromEntriesSpreadPossibleDuplicates.ts b/tsc/testdata/tests/cases/compiler/objectFromEntriesSpreadPossibleDuplicates.ts new file mode 100644 index 0000000000000..b65323ade4e1b --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/objectFromEntriesSpreadPossibleDuplicates.ts @@ -0,0 +1,8 @@ +// @target: es2020 +// @strict: true + +declare const icons: { iconName: "bicycle" | "book" }[]; +export const mapping = { + bicycle: 0, + ...Object.fromEntries(icons.map(icon => [icon.iconName, 1])), +}; diff --git a/tsc/testdata/tests/cases/compiler/partialDeepIntersectionCommonSupertype.ts b/tsc/testdata/tests/cases/compiler/partialDeepIntersectionCommonSupertype.ts new file mode 100644 index 0000000000000..8464824f475ee --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/partialDeepIntersectionCommonSupertype.ts @@ -0,0 +1,9 @@ +// @strict: true + +type PartialDeep = T extends object ? { [K in keyof T]?: PartialDeep } : T; +type Theme = T & { style: { message: (text: string) => string } }; +declare function makeTheme(...themes: PartialDeep>[]): Theme; +declare const theme: { style: { description: (text: string) => string } }; +declare const customization: PartialDeep>; +const merged = makeTheme(theme, customization); +merged.style.description(""); diff --git a/tsc/testdata/tests/cases/compiler/promiseAllArrayAssertionOverlap.ts b/tsc/testdata/tests/cases/compiler/promiseAllArrayAssertionOverlap.ts new file mode 100644 index 0000000000000..83245f871bc77 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/promiseAllArrayAssertionOverlap.ts @@ -0,0 +1,14 @@ +// @strict: true +// @target: es2015 + +interface Row { + [name: string]: any; +} +interface Entity { + id: number; +} +declare const result: Promise; + +export async function load() { + return (await Promise.all([result, result])) as Entity[]; +} diff --git a/tsc/testdata/tests/cases/compiler/promiseUnionCallbackStateInference.ts b/tsc/testdata/tests/cases/compiler/promiseUnionCallbackStateInference.ts new file mode 100644 index 0000000000000..33b15583d75e8 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/promiseUnionCallbackStateInference.ts @@ -0,0 +1,15 @@ +// @strict: true +// @target: es2015 + +declare function createAction( + action: (state: State) => State | Promise, + initialState: State, +): () => void; +declare function createAction( + action: (state: State, payload: string) => State | Promise, + initialState: State, +): (payload: string) => void; + +declare const action: (previous: unknown, value: string) => Promise; +const dispatch = createAction(action, null); +const bound = dispatch.bind(null, "value"); diff --git a/tsc/testdata/tests/cases/compiler/redundantNumericLiteralComparison.ts b/tsc/testdata/tests/cases/compiler/redundantNumericLiteralComparison.ts new file mode 100644 index 0000000000000..65662760ebd6a --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/redundantNumericLiteralComparison.ts @@ -0,0 +1,5 @@ +// @strict: true + +function shouldRetry(retryCount: number, currentCount: number) { + return retryCount === -1 || (retryCount !== -1 && currentCount <= retryCount); +} diff --git a/tsc/testdata/tests/cases/compiler/regexpConstructorMatchGroups.ts b/tsc/testdata/tests/cases/compiler/regexpConstructorMatchGroups.ts new file mode 100644 index 0000000000000..4268ecee7d664 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/regexpConstructorMatchGroups.ts @@ -0,0 +1,6 @@ +// @target: es2018 +// @strict: true + +declare const pattern: string; +const matches = "".match(new RegExp(pattern)); +if (matches) matches.groups; diff --git a/tsc/testdata/tests/cases/compiler/regexpGlobalConstructorMatchIteration.ts b/tsc/testdata/tests/cases/compiler/regexpGlobalConstructorMatchIteration.ts new file mode 100644 index 0000000000000..81e0d7c939b7d --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/regexpGlobalConstructorMatchIteration.ts @@ -0,0 +1,11 @@ +// @target: es2015 +// @strict: true + +declare const pattern: string; +declare function consume(value: string): void; +const matches = "".match(new RegExp(pattern, "g")); +if (matches) { + for (const match of matches) { + consume(match); + } +} diff --git a/tsc/testdata/tests/cases/compiler/regexpOptionalCaptureStringArray.ts b/tsc/testdata/tests/cases/compiler/regexpOptionalCaptureStringArray.ts new file mode 100644 index 0000000000000..107f62dd47b0b --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/regexpOptionalCaptureStringArray.ts @@ -0,0 +1,3 @@ +// @strict: true + +const result: string[] | null = /^(a)?$/.exec(""); diff --git a/tsc/testdata/tests/cases/compiler/regexpReplaceSingleParameterCallback.ts b/tsc/testdata/tests/cases/compiler/regexpReplaceSingleParameterCallback.ts new file mode 100644 index 0000000000000..79ccdf06bf869 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/regexpReplaceSingleParameterCallback.ts @@ -0,0 +1,6 @@ +// @target: es2015 +// @strict: true + +declare const pattern: RegExp; +declare const replace: (value: string) => string; +"".replace(pattern, replace); diff --git a/tsc/testdata/tests/cases/compiler/regexpUnmatchedCaptureIndices.ts b/tsc/testdata/tests/cases/compiler/regexpUnmatchedCaptureIndices.ts new file mode 100644 index 0000000000000..44a65b567901b --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/regexpUnmatchedCaptureIndices.ts @@ -0,0 +1,15 @@ +// @strict: true +// @target: es2022 +// @noEmit: true + +const match = /(section)?/d.exec(""); +if (match) { + match.indices![1][0]; + match.indices![1][1]; + + const indices = match.indices![1]; + if (indices) { + indices[0]; + indices[1]; + } +} diff --git a/tsc/testdata/tests/cases/compiler/routeComponentMetadata.ts b/tsc/testdata/tests/cases/compiler/routeComponentMetadata.ts new file mode 100644 index 0000000000000..3b4e14e75a151 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/routeComponentMetadata.ts @@ -0,0 +1,9 @@ +// @strict: true +// @noEmit: true + +type Component = (() => number) | ((() => number) & { readonly $$typeof: symbol }); +type RouteComponent = Component & { preload?: () => Promise }; +declare function createRoute(options: { component?: RouteComponent; validateSearch?: (search: unknown) => Search }): { useSearch(): Search }; +declare const schema: { parse(search: unknown): { page: number } }; +const route = createRoute({ component: () => 0, validateSearch: search => schema.parse(search) }); +route.useSearch().page; diff --git a/tsc/testdata/tests/cases/compiler/schemaCallableReturnMetadata.ts b/tsc/testdata/tests/cases/compiler/schemaCallableReturnMetadata.ts new file mode 100644 index 0000000000000..00d118c80d9c7 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/schemaCallableReturnMetadata.ts @@ -0,0 +1,13 @@ +// @strict: true +// @noEmit: true + +type Test = (() => void) & { options?: {} }; +interface ISchema { + resolve(): ISchema; + asNestedTest(): Test; +} + +class Schema implements ISchema { + resolve() { return this; } + asNestedTest(): () => void { return () => {}; } +} diff --git a/tsc/testdata/tests/cases/compiler/skippedCircularMatcherBases.ts b/tsc/testdata/tests/cases/compiler/skippedCircularMatcherBases.ts new file mode 100644 index 0000000000000..6f4854ab51cd5 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/skippedCircularMatcherBases.ts @@ -0,0 +1,14 @@ +// @skipLibCheck: true +// @strict: true + +// @filename: matchers.d.ts +interface Expect extends Matchers {} +interface MatcherResult {} +interface Matchers { + containing(value: string): unknown; +} +interface Matchers extends MatcherResult> {} +declare const expect: Expect; + +// @filename: main.ts +expect.containing("value"); diff --git a/tsc/testdata/tests/cases/compiler/skippedImplicitHandlerParameters.ts b/tsc/testdata/tests/cases/compiler/skippedImplicitHandlerParameters.ts new file mode 100644 index 0000000000000..9c3835ef078b9 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/skippedImplicitHandlerParameters.ts @@ -0,0 +1,18 @@ +// @skipLibCheck: true +// @strict: false +// @strictFunctionTypes: true + +// @filename: handlers.d.ts +interface FilterHandlers { + update: (value: object) => void; + remove: (value: string) => void; +} +interface ServerHandlers { + save: (value) => "saved"; +} +interface Handlers extends ServerHandlers, FilterHandlers {} + +// @filename: main.ts +function runHandler(handler: T, value: Parameters[0]) { + handler(value); +} diff --git a/tsc/testdata/tests/cases/compiler/starDefaultAssignmentCollision.ts b/tsc/testdata/tests/cases/compiler/starDefaultAssignmentCollision.ts new file mode 100644 index 0000000000000..f9485e4cebf97 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/starDefaultAssignmentCollision.ts @@ -0,0 +1,14 @@ +// @target: es2015 +// @module: esnext + +// @filename: first.ts +const first = 1; +export default first; + +// @filename: second.ts +const second = 2; +export default second; + +// @filename: barrel.ts +export * from "./first"; +export * from "./second"; diff --git a/tsc/testdata/tests/cases/compiler/strictSupertypeConcat.ts b/tsc/testdata/tests/cases/compiler/strictSupertypeConcat.ts new file mode 100644 index 0000000000000..80a46ae869877 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/strictSupertypeConcat.ts @@ -0,0 +1,19 @@ +// @strict: true +// @noEmit: true + +declare class User { + get initial(): string; +} +declare class Group { + memberCount: number; +} +interface Suggestion { + initial?: string; +} +type Many = Value | readonly Value[]; + +declare function concat(...values: Many[]): Value[]; +declare const pending: User[]; +declare const suggestions: (Group | Suggestion)[]; + +const items = concat(pending, suggestions); diff --git a/tsc/testdata/tests/cases/compiler/strictSupertypeInjection.ts b/tsc/testdata/tests/cases/compiler/strictSupertypeInjection.ts new file mode 100644 index 0000000000000..3deb664ccac63 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/strictSupertypeInjection.ts @@ -0,0 +1,19 @@ +// @strict: true +// @noEmit: true + +interface Reference { + get value(): Value; + set value(value: Value); +} +interface ComputedReference extends Reference { + readonly value: Value; + effect: unknown; +} +interface InjectionConstraint {} +type InjectionKey = symbol & InjectionConstraint; + +declare function inject(key: InjectionKey | string, fallback: Value): Value; +declare function ref(): Reference; +declare const key: InjectionKey<{ visibleIds: ComputedReference }>; + +const visibleIds = inject(key, { visibleIds: ref() }).visibleIds; diff --git a/tsc/testdata/tests/cases/compiler/strictSupertypeSchema.ts b/tsc/testdata/tests/cases/compiler/strictSupertypeSchema.ts new file mode 100644 index 0000000000000..ce8bab5d9368d --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/strictSupertypeSchema.ts @@ -0,0 +1,12 @@ +// @strict: true +// @noEmit: true + +interface Schema { + [name: string]: any; +} + +declare function choose(...callbacks: (() => Result)[]): Result; +declare const schema: Schema; + +const result = choose(() => ({}), () => schema); +result.$ref; diff --git a/tsc/testdata/tests/cases/compiler/syntheticDefaultCallbackContext.ts b/tsc/testdata/tests/cases/compiler/syntheticDefaultCallbackContext.ts new file mode 100644 index 0000000000000..af20053a8b902 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/syntheticDefaultCallbackContext.ts @@ -0,0 +1,18 @@ +// @strict: true +// @noEmit: true +// @module: commonjs +// @allowSyntheticDefaultImports: true + +// @filename: stream.d.ts +export interface Stream { + emit(event: string, data?: any): void; +} +export function through(write?: (this: Stream, data: any) => void, end?: (this: Stream) => void): Stream; + +// @filename: main.ts +import stream from "./stream"; +stream.through(function (data) { + this.emit("data", data); +}, function () { + this.emit("end"); +}); diff --git a/tsc/testdata/tests/cases/compiler/templateIndexedScopeOptions.ts b/tsc/testdata/tests/cases/compiler/templateIndexedScopeOptions.ts new file mode 100644 index 0000000000000..49647f464b1f3 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/templateIndexedScopeOptions.ts @@ -0,0 +1,7 @@ +// @strict: true +// @noEmit: true + +type Attributes = { name?: string } & { [path: `$${string}.${string}$`]: unknown }; +declare function scope(options: Attributes | { method: readonly [string, ...unknown[]] }): void; +const options = { method: ["list", { id: 1 }] }; +scope(options); diff --git a/tsc/testdata/tests/cases/compiler/transitiveStarDefaultCollision.ts b/tsc/testdata/tests/cases/compiler/transitiveStarDefaultCollision.ts new file mode 100644 index 0000000000000..3a0bd711d919e --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/transitiveStarDefaultCollision.ts @@ -0,0 +1,15 @@ +// @target: es2015 +// @module: esnext + +// @filename: first.ts +export default 1; + +// @filename: second.ts +export default 2; + +// @filename: nested.ts +export * from "./first"; + +// @filename: barrel.ts +export * from "./nested"; +export * from "./second"; diff --git a/tsc/testdata/tests/cases/compiler/typeOnlyStarDefaultCollision.ts b/tsc/testdata/tests/cases/compiler/typeOnlyStarDefaultCollision.ts new file mode 100644 index 0000000000000..bdfe17a17448c --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/typeOnlyStarDefaultCollision.ts @@ -0,0 +1,12 @@ +// @target: es2015 +// @module: esnext + +// @filename: first.ts +export default 1; + +// @filename: second.ts +export default 2; + +// @filename: barrel.ts +export type * from "./first"; +export type * from "./second"; diff --git a/tsc/testdata/tests/cases/compiler/typeOnlySyntheticDefaultImport.ts b/tsc/testdata/tests/cases/compiler/typeOnlySyntheticDefaultImport.ts new file mode 100644 index 0000000000000..5309149f3dd97 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/typeOnlySyntheticDefaultImport.ts @@ -0,0 +1,11 @@ +// @target: es2015 +// @module: commonjs +// @allowSyntheticDefaultImports: true +// @noEmit: true + +// @filename: library.d.ts +export function render(): void; + +// @filename: main.ts +import type { default as Library } from "./library"; +type LibraryType = typeof Library; diff --git a/tsc/testdata/tests/cases/compiler/undefinedPropertyTruthyReceiver.ts b/tsc/testdata/tests/cases/compiler/undefinedPropertyTruthyReceiver.ts new file mode 100644 index 0000000000000..c57cdbd2e5365 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/undefinedPropertyTruthyReceiver.ts @@ -0,0 +1,4 @@ +// @strict: true + +const state = { error: undefined }; +const renderedError = state.error ? state.error : ""; diff --git a/tsc/testdata/tests/cases/compiler/unknownAfterTypeofEarlyReturn.ts b/tsc/testdata/tests/cases/compiler/unknownAfterTypeofEarlyReturn.ts new file mode 100644 index 0000000000000..12735c004edf8 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/unknownAfterTypeofEarlyReturn.ts @@ -0,0 +1,12 @@ +// @target: es2021 +// @strict: true + +declare function fromString(value: string): number; +declare function fromBigint(value: bigint): number; +declare function fromNumber(value: number): boolean; +function coerce(value: unknown) { + if (typeof value === "boolean") return value; + if (typeof value === "string") return fromString(value); + if (typeof value === "bigint") return fromBigint(value); + if (typeof value === "number") return fromNumber(value); +} diff --git a/tsc/testdata/tests/cases/compiler/webSocketSendArrayBufferLike.ts b/tsc/testdata/tests/cases/compiler/webSocketSendArrayBufferLike.ts new file mode 100644 index 0000000000000..f323f8109bffa --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/webSocketSendArrayBufferLike.ts @@ -0,0 +1,8 @@ +// @strict: true +// @lib: es2024, dom +// @noEmit: true + +declare const socket: WebSocket; +declare const bytes: Uint8Array; +socket.send(bytes); +socket.send(new Uint8Array(8)); diff --git a/tsc/testdata/tests/cases/compiler/workerGlobalMessageHandlerThis.ts b/tsc/testdata/tests/cases/compiler/workerGlobalMessageHandlerThis.ts new file mode 100644 index 0000000000000..71f86148118c4 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/workerGlobalMessageHandlerThis.ts @@ -0,0 +1,9 @@ +// @strict: true +// @lib: es5,webworker +// @noEmit: true + +declare function createMessageReader(port: MessagePort | Worker | DedicatedWorkerGlobalScope): void; +createMessageReader(self); + +declare const event: MessageEvent; +self.onmessage?.(event); diff --git a/tsc/testdata/tests/cases/compiler/workerImplementationHandlerThis.ts b/tsc/testdata/tests/cases/compiler/workerImplementationHandlerThis.ts new file mode 100644 index 0000000000000..c02fe694ef209 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/workerImplementationHandlerThis.ts @@ -0,0 +1,11 @@ +// @strict: true +// @lib: es5,dom +// @noEmit: true + +declare class WorkerReplacement extends EventTarget implements Worker { + onmessage: ((this: Worker, event: MessageEvent) => any) | null; + onmessageerror: ((this: Worker, event: MessageEvent) => any) | null; + onerror: Worker["onerror"]; + postMessage: Worker["postMessage"]; + terminate: Worker["terminate"]; +} diff --git a/tsc/testdata/tests/cases/compiler/workerSubtypeHandlerThis.ts b/tsc/testdata/tests/cases/compiler/workerSubtypeHandlerThis.ts new file mode 100644 index 0000000000000..0027eeb358b82 --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/workerSubtypeHandlerThis.ts @@ -0,0 +1,11 @@ +// @strict: true +// @lib: es5,dom +// @noEmit: true + +interface MockWorker extends Worker { + messages: unknown[]; +} + +declare function forward(worker: Worker): void; +declare const worker: MockWorker; +forward(worker); diff --git a/tsc/testdata/tests/cases/conformance/moduleResolution/conditionalExportsRequireDefaultFallback.ts b/tsc/testdata/tests/cases/conformance/moduleResolution/conditionalExportsRequireDefaultFallback.ts new file mode 100644 index 0000000000000..c46205e93ecf7 --- /dev/null +++ b/tsc/testdata/tests/cases/conformance/moduleResolution/conditionalExportsRequireDefaultFallback.ts @@ -0,0 +1,24 @@ +// @module: commonjs +// @strict: true +// @noEmit: true +// @traceResolution: true +// @noImplicitReferences: true + +// @filename: /node_modules/provider/package.json +{ + "exports": { + ".": { + "require": "./index.cjs", + "default": "./index.js" + } + } +} + +// @filename: /node_modules/provider/index.cjs +exports.value = 0; + +// @filename: /node_modules/provider/index.d.ts +export const value: number; + +// @filename: /main.ts +import { value } from "provider"; diff --git a/tsc/testdata/tests/cases/conformance/moduleResolution/conditionalExportsResolutionFallbackNodeNext.ts b/tsc/testdata/tests/cases/conformance/moduleResolution/conditionalExportsResolutionFallbackNodeNext.ts new file mode 100644 index 0000000000000..6b904b42933df --- /dev/null +++ b/tsc/testdata/tests/cases/conformance/moduleResolution/conditionalExportsResolutionFallbackNodeNext.ts @@ -0,0 +1,31 @@ +// @target: es2022 +// @module: nodenext +// @moduleResolution: nodenext +// @strict: true +// @traceResolution: true +// @noTypesAndSymbols: true +// @noEmit: true +// @noImplicitReferences: true + +// @Filename: /node_modules/dep/package.json +{ + "name": "dep", + "version": "1.0.0", + "types": "./index.d.ts", + "exports": { + ".": { + "import": "./index.mjs", + "require": "./index.js", + "types": "./index.d.ts" + } + } +} + +// @Filename: /node_modules/dep/index.d.ts +export {}; + +// @Filename: /node_modules/dep/index.mjs +export {}; + +// @Filename: /index.mts +import {} from "dep";