Skip to content
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
1 change: 0 additions & 1 deletion internal/fourslash/_scripts/failingTests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ TestGetJavaScriptCompletions10
TestGetJavaScriptCompletions12
TestGetJavaScriptCompletions13
TestGetJavaScriptCompletions15
TestGetJavaScriptCompletions18
TestGetJavaScriptCompletions20
TestGetJavaScriptCompletions8
TestGetJavaScriptCompletions9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func TestGetJavaScriptCompletions18(t *testing.T) {
t.Parallel()
t.Skip()

defer testutil.RecoverAndFail(t, "Panic on fourslash test")
const content = `// @allowNonTsExtensions: true
// @Filename: file.js
Expand Down
4 changes: 4 additions & 0 deletions internal/parser/reparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,10 @@ func getFunctionLikeHost(host *ast.Node) (*ast.Node, bool) {
fun = host.Expression()
} else if host.Kind == ast.KindReturnStatement {
fun = host.Expression()
} else if host.Kind == ast.KindExpressionStatement {
if ast.IsBinaryExpression(host.Expression()) {
fun = host.Expression().AsBinaryExpression().Right
}
}
if ast.IsFunctionLike(fun) {
return fun, true
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,26 @@ module.exports = function loader(options) { };
export type Options = {
opt: string;
};
declare const _default: (options: any) => void;
declare const _default: (options: Options) => void;
export = _default;


//// [DtsFileErrors]


out/index.d.ts(9,1): error TS2309: An export assignment cannot be used in a module with other exported elements.


==== out/index.d.ts (1 errors) ====
/**
* @typedef Options
* @property {string} opt
*/
export type Options = {
opt: string;
};
declare const _default: (options: Options) => void;
export = _default;
~~~~~~~~~~~~~~~~~~
!!! error TS2309: An export assignment cannot be used in a module with other exported elements.

Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,26 @@
+export type Options = {
opt: string;
};
+declare const _default: (options: any) => void;
+export = _default;
+declare const _default: (options: Options) => void;
+export = _default;
+
+
+//// [DtsFileErrors]
+
+
+out/index.d.ts(9,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
+
+
+==== out/index.d.ts (1 errors) ====
+ /**
+ * @typedef Options
+ * @property {string} opt
+ */
+ export type Options = {
+ opt: string;
+ };
+ declare const _default: (options: Options) => void;
+ export = _default;
+ ~~~~~~~~~~~~~~~~~~
+!!! error TS2309: An export assignment cannot be used in a module with other exported elements.
+
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
* @param {Options} options
*/
module.exports = function loader(options) {}
>module.exports = function loader(options) {} : (options: any) => void
>module.exports : (options: any) => void
>module : { "export=": (options: any) => void; }
>exports : (options: any) => void
>function loader(options) {} : (options: any) => void
>loader : (options: any) => void
>options : any
>module.exports = function loader(options) {} : (options: Options) => void
>module.exports : (options: Options) => void
>module : { "export=": (options: Options) => void; }
>exports : (options: Options) => void
>function loader(options) {} : (options: Options) => void
>loader : (options: Options) => void
>options : Options

Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
--- old.jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.types
+++ new.jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.types
@@= skipped -9, +9 lines =@@
* @param {Options} options
*/
@@= skipped -11, +11 lines =@@
module.exports = function loader(options) {}
->module.exports = function loader(options) {} : (options: Options) => void
->module.exports : (options: Options) => void
>module.exports = function loader(options) {} : (options: Options) => void
>module.exports : (options: Options) => void
->module : { exports: (options: Options) => void; }
->exports : (options: Options) => void
->function loader(options) {} : (options: Options) => void
->loader : (options: Options) => void
->options : Options
+>module.exports = function loader(options) {} : (options: any) => void
+>module.exports : (options: any) => void
+>module : { "export=": (options: any) => void; }
+>exports : (options: any) => void
+>function loader(options) {} : (options: any) => void
+>loader : (options: any) => void
+>options : any
+>module : { "export=": (options: Options) => void; }
>exports : (options: Options) => void
>function loader(options) {} : (options: Options) => void
>loader : (options: Options) => void
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
jsElementAccessNoContextualTypeCrash.js(2,1): error TS2322: Type '{ localize: (string: any) => any; } | {}' is not assignable to type '{ localize: (string: any) => any; }'.
Property 'localize' is missing in type '{}' but required in type '{ localize: (string: any) => any; }'.
jsElementAccessNoContextualTypeCrash.js(2,1): error TS2322: Type '{ localize: (string: string) => string; } | {}' is not assignable to type '{ localize: (string: string) => string; }'.
Property 'localize' is missing in type '{}' but required in type '{ localize: (string: string) => string; }'.


==== jsElementAccessNoContextualTypeCrash.js (1 errors) ====
var Common = {};
self['Common'] = self['Common'] || {};
~~~~~~~~~~~~~~
!!! error TS2322: Type '{ localize: (string: any) => any; } | {}' is not assignable to type '{ localize: (string: any) => any; }'.
!!! error TS2322: Property 'localize' is missing in type '{}' but required in type '{ localize: (string: any) => any; }'.
!!! error TS2322: Type '{ localize: (string: string) => string; } | {}' is not assignable to type '{ localize: (string: string) => string; }'.
!!! error TS2322: Property 'localize' is missing in type '{}' but required in type '{ localize: (string: string) => string; }'.
!!! related TS2728 jsElementAccessNoContextualTypeCrash.js:7:1: 'localize' is declared here.
/**
* @param {string} string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
+++ new.jsElementAccessNoContextualTypeCrash.errors.txt
@@= skipped -0, +0 lines =@@
-jsElementAccessNoContextualTypeCrash.js(2,1): error TS2741: Property 'localize' is missing in type '{}' but required in type 'typeof Common'.
+jsElementAccessNoContextualTypeCrash.js(2,1): error TS2322: Type '{ localize: (string: any) => any; } | {}' is not assignable to type '{ localize: (string: any) => any; }'.
+ Property 'localize' is missing in type '{}' but required in type '{ localize: (string: any) => any; }'.
+jsElementAccessNoContextualTypeCrash.js(2,1): error TS2322: Type '{ localize: (string: string) => string; } | {}' is not assignable to type '{ localize: (string: string) => string; }'.
+ Property 'localize' is missing in type '{}' but required in type '{ localize: (string: string) => string; }'.


==== jsElementAccessNoContextualTypeCrash.js (1 errors) ====
var Common = {};
self['Common'] = self['Common'] || {};
~~~~~~~~~~~~~~
-!!! error TS2741: Property 'localize' is missing in type '{}' but required in type 'typeof Common'.
+!!! error TS2322: Type '{ localize: (string: any) => any; } | {}' is not assignable to type '{ localize: (string: any) => any; }'.
+!!! error TS2322: Property 'localize' is missing in type '{}' but required in type '{ localize: (string: any) => any; }'.
+!!! error TS2322: Type '{ localize: (string: string) => string; } | {}' is not assignable to type '{ localize: (string: string) => string; }'.
+!!! error TS2322: Property 'localize' is missing in type '{}' but required in type '{ localize: (string: string) => string; }'.
!!! related TS2728 jsElementAccessNoContextualTypeCrash.js:7:1: 'localize' is declared here.
/**
* @param {string} string
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

=== jsElementAccessNoContextualTypeCrash.js ===
var Common = {};
>Common : { localize: (string: any) => any; }
>{} : { localize: (string: any) => any; }
>Common : { localize: (string: string) => string; }
>{} : { localize: (string: string) => string; }

self['Common'] = self['Common'] || {};
>self['Common'] = self['Common'] || {} : { localize: (string: any) => any; } | {}
>self['Common'] : { localize: (string: any) => any; }
>self['Common'] = self['Common'] || {} : { localize: (string: string) => string; } | {}
>self['Common'] : { localize: (string: string) => string; }
>self : Window & typeof globalThis
>'Common' : "Common"
>self['Common'] || {} : { localize: (string: any) => any; } | {}
>self['Common'] : { localize: (string: any) => any; }
>self['Common'] || {} : { localize: (string: string) => string; } | {}
>self['Common'] : { localize: (string: string) => string; }
>self : Window & typeof globalThis
>'Common' : "Common"
>{} : {}
Expand All @@ -21,14 +21,14 @@ self['Common'] = self['Common'] || {};
* @return {string}
*/
Common.localize = function (string) {
>Common.localize = function (string) { return string;} : (string: any) => any
>Common.localize : (string: any) => any
>Common : { localize: (string: any) => any; }
>localize : (string: any) => any
>function (string) { return string;} : (string: any) => any
>string : any
>Common.localize = function (string) { return string;} : (string: string) => string
>Common.localize : (string: string) => string
>Common : { localize: (string: string) => string; }
>localize : (string: string) => string
>function (string) { return string;} : (string: string) => string
>string : string

return string;
>string : any
>string : string

};
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,29 @@
var Common = {};
->Common : typeof Common
->{} : {}
+>Common : { localize: (string: any) => any; }
+>{} : { localize: (string: any) => any; }
+>Common : { localize: (string: string) => string; }
+>{} : { localize: (string: string) => string; }

self['Common'] = self['Common'] || {};
->self['Common'] = self['Common'] || {} : {}
->self['Common'] : typeof Common
+>self['Common'] = self['Common'] || {} : { localize: (string: any) => any; } | {}
+>self['Common'] : { localize: (string: any) => any; }
+>self['Common'] = self['Common'] || {} : { localize: (string: string) => string; } | {}
+>self['Common'] : { localize: (string: string) => string; }
>self : Window & typeof globalThis
>'Common' : "Common"
->self['Common'] || {} : {}
->self['Common'] : typeof Common
+>self['Common'] || {} : { localize: (string: any) => any; } | {}
+>self['Common'] : { localize: (string: any) => any; }
+>self['Common'] || {} : { localize: (string: string) => string; } | {}
+>self['Common'] : { localize: (string: string) => string; }
>self : Window & typeof globalThis
>'Common' : "Common"
>{} : {}
@@= skipped -19, +19 lines =@@
* @return {string}
*/
@@= skipped -21, +21 lines =@@
Common.localize = function (string) {
->Common.localize = function (string) { return string;} : (string: string) => string
->Common.localize : (string: string) => string
>Common.localize = function (string) { return string;} : (string: string) => string
>Common.localize : (string: string) => string
->Common : typeof Common
->localize : (string: string) => string
->function (string) { return string;} : (string: string) => string
->string : string
+>Common.localize = function (string) { return string;} : (string: any) => any
+>Common.localize : (string: any) => any
+>Common : { localize: (string: any) => any; }
+>localize : (string: any) => any
+>function (string) { return string;} : (string: any) => any
+>string : any

return string;
->string : string
+>string : any

};
+>Common : { localize: (string: string) => string; }
>localize : (string: string) => string
>function (string) { return string;} : (string: string) => string
>string : string
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ export function Foo() { }
* @return {void}
*/
Foo.prototype.bar = function (a, b) { }
>Foo.prototype.bar = function (a, b) { } : (a: any, b: any) => void
>Foo.prototype.bar = function (a, b) { } : (a: string | number, b?: string) => void
>Foo.prototype.bar : any
>Foo.prototype : any
>Foo : () => void
>prototype : any
>bar : any
>function (a, b) { } : (a: any, b: any) => void
>a : any
>b : any
>function (a, b) { } : (a: string | number, b?: string) => void
>a : string | number
>b : string

Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@
*/
Foo.prototype.bar = function (a, b) { }
->Foo.prototype.bar = function (a, b) { } : { (a: string): void; (a: number, b: string): void; }
+>Foo.prototype.bar = function (a, b) { } : (a: any, b: any) => void
+>Foo.prototype.bar = function (a, b) { } : (a: string | number, b?: string) => void
>Foo.prototype.bar : any
>Foo.prototype : any
->Foo : typeof Foo
+>Foo : () => void
>prototype : any
>bar : any
->function (a, b) { } : { (a: string): void; (a: number, b: string): void; }
->a : string | number
->b : string
+>function (a, b) { } : (a: any, b: any) => void
+>a : any
+>b : any
+>function (a, b) { } : (a: string | number, b?: string) => void
>a : string | number
>b : string
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ var y;
* @param {boolean!} b
*/
y = function bar(b) {}
>y = function bar(b) {} : (b: any) => void
>y = function bar(b) {} : (b: boolean) => void
>y : any
>function bar(b) {} : (b: any) => void
>bar : (b: any) => void
>b : any
>function bar(b) {} : (b: boolean) => void
>bar : (b: boolean) => void
>b : boolean

/**
* @param {string} s
Expand Down
Loading