Skip to content

Filter transient flags to fix useDefineForClassFields #43055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//// [intersectionType_useDefineForClassFields.ts]
type Foo<T> = {
[k in keyof T & string]: any
}

function bar<T>(_p: T): { new(): Foo<T> } {
return null as any;
}

class Baz extends bar({ x: 1 }) {
}

//// [intersectionType_useDefineForClassFields.js]
function bar(_p) {
return null;
}
class Baz extends bar({ x: 1 }) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
=== tests/cases/compiler/intersectionType_useDefineForClassFields.ts ===
type Foo<T> = {
>Foo : Symbol(Foo, Decl(intersectionType_useDefineForClassFields.ts, 0, 0))
>T : Symbol(T, Decl(intersectionType_useDefineForClassFields.ts, 0, 9))

[k in keyof T & string]: any
>k : Symbol(k, Decl(intersectionType_useDefineForClassFields.ts, 1, 5))
>T : Symbol(T, Decl(intersectionType_useDefineForClassFields.ts, 0, 9))
}

function bar<T>(_p: T): { new(): Foo<T> } {
>bar : Symbol(bar, Decl(intersectionType_useDefineForClassFields.ts, 2, 1))
>T : Symbol(T, Decl(intersectionType_useDefineForClassFields.ts, 4, 13))
>_p : Symbol(_p, Decl(intersectionType_useDefineForClassFields.ts, 4, 16))
>T : Symbol(T, Decl(intersectionType_useDefineForClassFields.ts, 4, 13))
>Foo : Symbol(Foo, Decl(intersectionType_useDefineForClassFields.ts, 0, 0))
>T : Symbol(T, Decl(intersectionType_useDefineForClassFields.ts, 4, 13))

return null as any;
}

class Baz extends bar({ x: 1 }) {
>Baz : Symbol(Baz, Decl(intersectionType_useDefineForClassFields.ts, 6, 1))
>bar : Symbol(bar, Decl(intersectionType_useDefineForClassFields.ts, 2, 1))
>x : Symbol(x, Decl(intersectionType_useDefineForClassFields.ts, 8, 23))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
=== tests/cases/compiler/intersectionType_useDefineForClassFields.ts ===
type Foo<T> = {
>Foo : Foo<T>

[k in keyof T & string]: any
}

function bar<T>(_p: T): { new(): Foo<T> } {
>bar : <T>(_p: T) => { new (): Foo<T>;}
>_p : T

return null as any;
>null as any : any
>null : null
}

class Baz extends bar({ x: 1 }) {
>Baz : Baz
>bar({ x: 1 }) : Foo<{ x: number; }>
>bar : <T>(_p: T) => new () => Foo<T>
>{ x: 1 } : { x: number; }
>x : number
>1 : 1
}
13 changes: 13 additions & 0 deletions tests/cases/compiler/intersectionType_useDefineForClassFields.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// @target: ESNext
// @useDefineForClassFields: true

type Foo<T> = {
[k in keyof T & string]: any
}

function bar<T>(_p: T): { new(): Foo<T> } {
return null as any;
}

class Baz extends bar({ x: 1 }) {
}