Skip to content

Class inference from prototypes in JavaScript #5578

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

Conversation

RyanCavanaugh
Copy link
Member

In this PR:

  • Assignments to func.prototype.member
    • Mark func as an "inferred class"
    • Turn func's call signature into a construct signature
    • Add member to the prototype property of func
  • Assignments to this.member in the body of an "inferred class" function implementation add a member instance property to the return type of func's construct signature
  • Invocations of an "inferred class" get the members of its prototype property along with its instance members

Implementation details

  • Unified the logic around all the different special property assignment kinds we have now (assignments to module.exports, exports, this., or func.prototype.member
  • Add a kind to Signature (call vs construct) because it is no longer possible to distinguish them syntactically
  • Made fourslash's debug functions for quick info, member list, and completion list produce human-readable output instead of JSON

Merge incoming but wanted to get this posted

DanielRosenwasser and others added 29 commits November 11, 2015 12:25
…vices

Do not get the apparent type for 'getContextualType' in the services layer
… --sourceRoot

Note that --sourceRoot fails with crash
added missing check if file is specified
Fixes use of combination of options sourceRoot and mapRoot with inlineSourceMap and inlineSources
…nCaseClause

always check statements in case clause
…fig.json

Since we dont support arbitary list of extensions to treat as .js,
it becomes easier to simplify code based on the assumptions
DanielRosenwasser and others added 26 commits November 28, 2015 12:00
ignore all trivia except singleline comments when processing triplesl…
Fix completion and quick info crash in type parameter in function in type alias
Extract source map generation logic out of the emitter.
…ntDecorators

Various fixes for sourcemap and breakpoints of decorators
…edVoid

do not report 'noImplicitReturns' error if inferred return type of th…
Do not emit names and name index mapping in source map
Sync the dom.generated.d.ts files from TSJS repo
Give more helpful error when trying to set default values on an interface.
# Conflicts:
#	src/compiler/binder.ts
#	src/compiler/checker.ts
#	src/harness/fourslash.ts
@RyanCavanaugh
Copy link
Member Author

Closing in favor of #5876

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.