Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

This function types #6739

Merged
merged 46 commits into from
Apr 7, 2016
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
0a968f0
Parse this type using parameter syntax
sandersn Jan 29, 2016
d8a77c0
Check this type in functions.
sandersn Jan 29, 2016
a639b71
Skip emit of this types as first parameter.
sandersn Jan 29, 2016
9bd7afb
Add new error message and strictThis flag
sandersn Jan 29, 2016
ca16209
Make compiler strictThis clean.
sandersn Jan 29, 2016
22e571f
Add services support for this types.
sandersn Jan 29, 2016
5fe8478
Add overloads for Function.apply/call/bind
sandersn Jan 29, 2016
04e7d81
Add tests and baselines for this-function types.
sandersn Jan 29, 2016
a4f1154
Fix free function bug in cachingInServerLSHost
sandersn Jan 29, 2016
d030889
Update baselines
sandersn Jan 29, 2016
675e081
Make this-type of bind's return explicit
sandersn Feb 2, 2016
f6361ce
Undo strictThis-clean changes
sandersn Feb 3, 2016
8032b06
Merge branch 'master' into this-function-types
sandersn Feb 3, 2016
0af56c0
Update error numbers in new tests after merge
sandersn Feb 3, 2016
8c87da5
First round of review comments addressed.
sandersn Feb 4, 2016
2f74da1
Add specific error messages for out-of-place this
sandersn Feb 5, 2016
71488fc
Refactorings from review comments
sandersn Feb 5, 2016
5821b87
Do not contextually type object callee arguments
sandersn Feb 5, 2016
80de700
Get contextual type of this parameter correctly
sandersn Feb 6, 2016
fa59875
Improve display and contextual typing of `this`
sandersn Feb 8, 2016
738713b
Improve error reporting
sandersn Feb 8, 2016
41bb446
Revert unioning of this argument types
sandersn Feb 9, 2016
a014edf
Address more comments and remove temp test.
sandersn Feb 16, 2016
e7aa7e4
Merge branch 'master' into this-function-types
sandersn Feb 16, 2016
482accc
Union this-types of unioned call signatures
sandersn Mar 8, 2016
7b531fc
Check this expressions in object literal methods
sandersn Mar 9, 2016
4012587
Update baselines: 'this' in object literal methods
sandersn Mar 9, 2016
3297824
Add missed update of thisInObjectLiterals baseline
sandersn Mar 9, 2016
fa22250
Merge branch 'master' into this-function-types
sandersn Mar 9, 2016
3a46e72
After merge, update error numbers in baselines
sandersn Mar 9, 2016
1032cc5
Rename --strictThis to --strictThisChecks
sandersn Mar 11, 2016
c9f5f3d
Remove --strictThisChecks
sandersn Mar 25, 2016
a91cdcc
Add --noImplicitThis flag
sandersn Mar 25, 2016
9e5f260
Merge branch 'master' into this-function-types
sandersn Mar 28, 2016
f64110a
Update baselines after merging from master
sandersn Mar 28, 2016
0113ad5
Error on all uses of this that are implicitly any
sandersn Mar 30, 2016
e4ed7f9
Address PR comments
sandersn Mar 30, 2016
0060b4d
Test that signature help doesn't show 'this'
sandersn Mar 31, 2016
da98258
Improve error messages and code style
sandersn Mar 31, 2016
ce68932
Merge branch 'master' into this-function-types
sandersn Mar 31, 2016
81f0d86
Fix up baselines and missing , after merge
sandersn Mar 31, 2016
4197a30
Improve error messages and always return any from newed functions
sandersn Mar 31, 2016
9e5fba6
Prepend 'the' to a couple of ambiguous messages.
sandersn Apr 1, 2016
2a9f39b
Forbid ConstructType as part of 'no this in constructors'
sandersn Apr 1, 2016
921d5f8
Fix == typo and add object literal 'this' test
sandersn Apr 1, 2016
6c735b5
Add contextual typing test with `this` specified
sandersn Apr 7, 2016
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
3 changes: 3 additions & 0 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,9 @@ namespace ts {
// as other properties in the object literal. So we use SymbolFlags.PropertyExcludes
// so that it will conflict with any other object literal members with the same
// name.
if (options.strictThis) {
seenThisKeyword = true;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So any interface containing a method is now generic. Probably unavoidable, but we should get some data on what it means for performance.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran some numbers this afternoon and didn't see a big change. Could be misreading the results though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to recap your findings: On the Monaco project this ends up adding as much as 10% to the check time for an overall impact of up to 5%.

return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.Method | ((<MethodDeclaration>node).questionToken ? SymbolFlags.Optional : SymbolFlags.None),
isObjectLiteralMethod(node) ? SymbolFlags.PropertyExcludes : SymbolFlags.MethodExcludes);
case SyntaxKind.FunctionDeclaration:
Expand Down
159 changes: 130 additions & 29 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/compiler/commandLineParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ namespace ts {
name: "skipDefaultLibCheck",
type: "boolean",
},
{
name: "strictThis",
type: "boolean",
},
{
name: "out",
type: "string",
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,10 @@
"category": "Error",
"code": 2670
},
"A function that is called with the 'new' keyword cannot have a 'this' type that is void.": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Void in single quotes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"category": "Error",
"code": 2671
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4436,8 +4436,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
write("(");
if (node) {
const parameters = node.parameters;
const skipCount = node.parameters.length && (<Identifier>node.parameters[0].name).text === "this" ? 1 : 0;
const omitCount = languageVersion < ScriptTarget.ES6 && hasRestParameter(node) ? 1 : 0;
emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false);
emitList(parameters, skipCount, parameters.length - omitCount - skipCount, /*multiLine*/ false, /*trailingComma*/ false);
}
write(")");
decreaseIndent();
Expand Down
28 changes: 16 additions & 12 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,7 @@ namespace ts {
};

// Parses a comma-delimited list of elements
function parseDelimitedList<T extends Node>(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimeter?: boolean): NodeArray<T> {
function parseDelimitedList<T extends Node>(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimiter?: boolean): NodeArray<T> {
const saveParsingContext = parsingContext;
parsingContext |= 1 << kind;
const result = <NodeArray<T>>[];
Expand Down Expand Up @@ -1751,7 +1751,7 @@ namespace ts {
// parse errors. For example, this can happen when people do things like use
// a semicolon to delimit object literal members. Note: we'll have already
// reported an error when we called parseExpected above.
if (considerSemicolonAsDelimeter && token === SyntaxKind.SemicolonToken && !scanner.hasPrecedingLineBreak()) {
if (considerSemicolonAsDelimiter && token === SyntaxKind.SemicolonToken && !scanner.hasPrecedingLineBreak()) {
nextToken();
}
continue;
Expand Down Expand Up @@ -2002,7 +2002,7 @@ namespace ts {
}

function isStartOfParameter(): boolean {
return token === SyntaxKind.DotDotDotToken || isIdentifierOrPattern() || isModifierKind(token) || token === SyntaxKind.AtToken;
return token === SyntaxKind.DotDotDotToken || isIdentifierOrPattern() || isModifierKind(token) || token === SyntaxKind.AtToken || token === SyntaxKind.ThisKeyword;
}

function setModifiers(node: Node, modifiers: ModifiersArray) {
Expand All @@ -2014,15 +2014,19 @@ namespace ts {

function parseParameter(): ParameterDeclaration {
const node = <ParameterDeclaration>createNode(SyntaxKind.Parameter);
if (token === SyntaxKind.ThisKeyword) {
node.name = createIdentifier(/*isIdentifier*/true, undefined);
node.type = parseParameterType();
return finishNode(node);
}

node.decorators = parseDecorators();
setModifiers(node, parseModifiers());
node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken);

// FormalParameter [Yield,Await]:
// BindingElement[?Yield,?Await]

node.name = parseIdentifierOrPattern();

if (getFullWidth(node.name) === 0 && node.flags === 0 && isModifierKind(token)) {
// in cases like
// 'use strict'
Expand Down Expand Up @@ -2060,11 +2064,11 @@ namespace ts {
}

function fillSignature(
returnToken: SyntaxKind,
yieldContext: boolean,
awaitContext: boolean,
requireCompleteParameterList: boolean,
signature: SignatureDeclaration): void {
returnToken: SyntaxKind,
yieldContext: boolean,
awaitContext: boolean,
requireCompleteParameterList: boolean,
signature: SignatureDeclaration): void {

const returnTokenRequired = returnToken === SyntaxKind.EqualsGreaterThanToken;
signature.typeParameters = parseTypeParameters();
Expand Down Expand Up @@ -2464,7 +2468,7 @@ namespace ts {
// ( ...
return true;
}
if (isIdentifier() || isModifierKind(token)) {
if (isIdentifier() || isModifierKind(token) || token === SyntaxKind.ThisKeyword) {
nextToken();
if (token === SyntaxKind.ColonToken || token === SyntaxKind.CommaToken ||
token === SyntaxKind.QuestionToken || token === SyntaxKind.EqualsToken ||
Expand Down Expand Up @@ -3981,7 +3985,7 @@ namespace ts {
node.flags |= NodeFlags.MultiLine;
}

node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true);
node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
parseExpected(SyntaxKind.CloseBraceToken);
return finishNode(node);
}
Expand Down
4 changes: 3 additions & 1 deletion src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,7 @@ namespace ts {
buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildTypeParameterDisplayFromSymbol(symbol: Symbol, writer: SymbolWriter, enclosingDeclaraiton?: Node, flags?: TypeFormatFlags): void;
buildDisplayForParametersAndDelimiters(parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildDisplayForParametersAndDelimiters(thisType: Type, parameters: Symbol[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildDisplayForTypeParametersAndDelimiters(typeParameters: TypeParameter[], writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
buildReturnTypeDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void;
}
Expand Down Expand Up @@ -2279,6 +2279,7 @@ namespace ts {
declaration: SignatureDeclaration; // Originating declaration
typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic)
parameters: Symbol[]; // Parameters
thisType?: Type; // type of this-type
/* @internal */
resolvedReturnType: Type; // Resolved return type
/* @internal */
Expand Down Expand Up @@ -2429,6 +2430,7 @@ namespace ts {
rootDir?: string;
sourceMap?: boolean;
sourceRoot?: string;
strictThis?: boolean;
suppressExcessPropertyErrors?: boolean;
suppressImplicitAnyIndexErrors?: boolean;
target?: ScriptTarget;
Expand Down
4 changes: 2 additions & 2 deletions src/harness/loggedIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ namespace Playback {
(path, extension, exclude) => findResultByPath(wrapper, replayLog.directoriesRead.filter(d => d.extension === extension && ts.arrayIsEqualTo(d.exclude, exclude)), path));

wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)(
(path, contents) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }),
(path, contents) => noOpReplay("writeFile"));
(path: string, contents: string) => callAndRecord(underlying.writeFile(path, contents), recordLog.filesWritten, { path, contents, bom: false }),
(path: string, contents: string) => noOpReplay("writeFile"));

wrapper.exit = (exitCode) => {
if (recordLog !== undefined) {
Expand Down
9 changes: 6 additions & 3 deletions src/lib/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,22 +215,25 @@ interface Function {
* @param thisArg The object to be used as the this object.
* @param argArray A set of arguments to be passed to the function.
*/
apply(thisArg: any, argArray?: any): any;
apply<T,U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U;
apply(this: Function, thisArg: any, argArray?: any): any;

/**
* Calls a method of an object, substituting another object for the current object.
* @param thisArg The object to be used as the current object.
* @param argArray A list of arguments to be passed to the method.
*/
call(thisArg: any, ...argArray: any[]): any;
call<T,U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after comma before U for call and apply

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

call(this: Function, thisArg: any, ...argArray: any[]): any;

/**
* For a given function, creates a bound function that has the same body as the original function.
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
* @param thisArg An object to which the this keyword can refer inside the new function.
* @param argArray A list of arguments to be passed to the new function.
*/
bind(thisArg: any, ...argArray: any[]): any;
bind<T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): (this: void, ...argArray: any[]) => U;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't you want to place some constraint between T and U?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T is the function's this type. U is the function's return value. There's no relation between them. I don't know TypeScript's conventions for type variable names that well. Would it be easier to read to change this to <TThis, TReturn>?

bind(this: Function, thisArg: any, ...argArray: any[]): any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you need the explicit this-arg?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I would like this to show up in the quick info. It's quite relevant to this method.
  2. I want to say this: Function instead of this: this because it's a smaller type (thus, easier to call, harder to implement). I hope you can't monkey patch bind so implementation of bind shouldn't be an issue ... I'll go see what I can learn about that. It seems like something people might actually do in javascript.
  3. this: Function is easier to read than this: this for first-time readers of this parameters.
  4. Uniformity with the first overload.


prototype: any;
readonly length: number;
Expand Down
21 changes: 17 additions & 4 deletions src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ namespace ts {
declaration: SignatureDeclaration;
typeParameters: TypeParameter[];
parameters: Symbol[];
thisType: Type;
resolvedReturnType: Type;
minArgumentCount: number;
hasRestParameter: boolean;
Expand Down Expand Up @@ -4021,6 +4022,9 @@ namespace ts {
if (typeChecker.isArgumentsSymbol(symbol)) {
return ScriptElementKind.localVariableElement;
}
if (location.kind === SyntaxKind.ThisKeyword && isExpression(location)) {
return ScriptElementKind.parameterElement;
}
if (flags & SymbolFlags.Variable) {
if (isFirstDeclarationOfSymbolParameter(symbol)) {
return ScriptElementKind.parameterElement;
Expand Down Expand Up @@ -4083,6 +4087,7 @@ namespace ts {
const symbolFlags = symbol.flags;
let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location);
let hasAddedSymbolInfo: boolean;
const isThisExpression: boolean = location.kind === SyntaxKind.ThisKeyword && isExpression(location);
let type: Type;

// Class at constructor site need to be shown as constructor apart from property,method, vars
Expand All @@ -4093,7 +4098,7 @@ namespace ts {
}

let signature: Signature;
type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location);
if (type) {
if (location.parent && location.parent.kind === SyntaxKind.PropertyAccessExpression) {
const right = (<PropertyAccessExpression>location.parent).name;
Expand Down Expand Up @@ -4204,7 +4209,7 @@ namespace ts {
}
}
}
if (symbolFlags & SymbolFlags.Class && !hasAddedSymbolInfo) {
if (symbolFlags & SymbolFlags.Class && !hasAddedSymbolInfo && !isThisExpression) {
if (getDeclarationOfKind(symbol, SyntaxKind.ClassExpression)) {
// Special case for class expressions because we would like to indicate that
// the class name is local to the class body (similar to function expression)
Expand Down Expand Up @@ -4346,11 +4351,19 @@ namespace ts {
if (!hasAddedSymbolInfo) {
if (symbolKind !== ScriptElementKind.unknown) {
if (type) {
addPrefixForAnyFunctionOrVar(symbol, symbolKind);
if (isThisExpression) {
addNewLineIfDisplayPartsExist();
displayParts.push(keywordPart(SyntaxKind.ThisKeyword));
}
else {
addPrefixForAnyFunctionOrVar(symbol, symbolKind);
}

// For properties, variables and local vars: show the type
if (symbolKind === ScriptElementKind.memberVariableElement ||
symbolFlags & SymbolFlags.Variable ||
symbolKind === ScriptElementKind.localVariableElement) {
symbolKind === ScriptElementKind.localVariableElement ||
isThisExpression) {
displayParts.push(punctuationPart(SyntaxKind.ColonToken));
displayParts.push(spacePart());
// If the type is type parameter, format it specially
Expand Down
2 changes: 1 addition & 1 deletion src/services/signatureHelp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ namespace ts.SignatureHelp {
signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray;
suffixDisplayParts.push(punctuationPart(SyntaxKind.GreaterThanToken));
let parameterParts = mapToDisplayParts(writer =>
typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation));
typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisType, candidateSignature.parameters, writer, invocation));
addRange(suffixDisplayParts, parameterParts);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tests/cases/compiler/assignmentToObjectAndFunction.ts(8,5): error TS2322: Type '
Property 'apply' is missing in type '{}'.
tests/cases/compiler/assignmentToObjectAndFunction.ts(29,5): error TS2322: Type 'typeof bad' is not assignable to type 'Function'.
Types of property 'apply' are incompatible.
Type 'number' is not assignable to type '(thisArg: any, argArray?: any) => any'.
Type 'number' is not assignable to type '{ <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }'.


==== tests/cases/compiler/assignmentToObjectAndFunction.ts (3 errors) ====
Expand Down Expand Up @@ -48,4 +48,4 @@ tests/cases/compiler/assignmentToObjectAndFunction.ts(29,5): error TS2322: Type
~~~~~~~~~~
!!! error TS2322: Type 'typeof bad' is not assignable to type 'Function'.
!!! error TS2322: Types of property 'apply' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type '(thisArg: any, argArray?: any) => any'.
!!! error TS2322: Type 'number' is not assignable to type '{ <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }'.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class C {

var fn = async () => await other.apply(this, arguments);
>fn : Symbol(fn, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 3, 9))
>other.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --))
>other.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 1, 13))
>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --))
>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es6.ts, 0, 0))
>arguments : Symbol(arguments)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ class C {
>other : () => void

var fn = async () => await other.apply(this, arguments);
>fn : () => Promise<any>
>async () => await other.apply(this, arguments) : () => Promise<any>
>await other.apply(this, arguments) : any
>other.apply(this, arguments) : any
>other.apply : (thisArg: any, argArray?: any) => any
>fn : () => Promise<void>
>async () => await other.apply(this, arguments) : () => Promise<void>
>await other.apply(this, arguments) : void
>other.apply(this, arguments) : void
>other.apply : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }
>other : () => void
>apply : (thisArg: any, argArray?: any) => any
>apply : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, argArray?: any): U; (this: Function, thisArg: any, argArray?: any): any; }
>this : this
>arguments : IArguments
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function fn(x = () => this, y = x()) {
}

fn.call(4); // Should be 4
>fn.call : Symbol(Function.call, Decl(lib.d.ts, --, --))
>fn.call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>fn : Symbol(fn, Decl(fatarrowfunctionsInFunctionParameterDefaults.ts, 0, 0))
>call : Symbol(Function.call, Decl(lib.d.ts, --, --))
>call : Symbol(Function.call, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))

Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function fn(x = () => this, y = x()) {

fn.call(4); // Should be 4
>fn.call(4) : any
>fn.call : (thisArg: any, ...argArray: any[]) => any
>fn.call : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; }
>fn : (x?: () => any, y?: any) => any
>call : (thisArg: any, ...argArray: any[]) => any
>call : { <T, U>(this: (this: T, ...argArray: any[]) => U, thisArg: T, ...argArray: any[]): U; (this: Function, thisArg: any, ...argArray: any[]): any; }
>4 : number

4 changes: 2 additions & 2 deletions tests/baselines/reference/functionType.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ function salt() {}
>salt : Symbol(salt, Decl(functionType.ts, 0, 0))

salt.apply("hello", []);
>salt.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --))
>salt.apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>salt : Symbol(salt, Decl(functionType.ts, 0, 0))
>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --))
>apply : Symbol(Function.apply, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))

(new Function("return 5"))();
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
Expand Down
Loading