Repository navigation
api-extractor initial support for generating *.d.ts files - #448
Conversation
| ], | ||
| 'strictNullChecks': true | ||
| }, | ||
| 'include': [ 'lib/**/*.d.ts' ] |
There was a problem hiding this comment.
'include': [ 'lib/**/*.d.ts' ] [](start = 8, length = 30)
Go figure out how this is going to work with GCB. #Pending
There was a problem hiding this comment.
I've got a working prototype of this, but it needs to go in a separate PR branch. It may also require a major version bump for API Extractor.
In reply to: 152421152 [](ancestors = 152421152)
|
|
||
| console.log('CONFIG:' + JSON.stringify(extractor.config, undefined, ' ')); | ||
|
|
||
| extractor.analyzeProject(); |
There was a problem hiding this comment.
analyzeProject [](start = 10, length = 14)
Rename to processProject #Resolved
There was a problem hiding this comment.
| * The default value is "index-internal.d.ts". This file will contain all definitions that | ||
| * are reachable from the entry point. | ||
| */ | ||
| internalFilename?: string; |
There was a problem hiding this comment.
Make it more clear that this gets appended to outputFolder. #Resolved
There was a problem hiding this comment.
You could consider renaming these to FilePath instead of Filename
In reply to: 152421826 [](ancestors = 152421826)
| * are reachable from the entry point, except definitions marked as \@beta, \@alpha, | ||
| * or \@internal. | ||
| */ | ||
| publicFilename?: string; |
There was a problem hiding this comment.
My first guess is that these paths are inputs. Make sure it's clear from the names that they're outputs. #Resolved
| * It is provided for diagnostic purposes. For example, a build script could write | ||
| * this object to a JSON file to report the final configuration options used by API Extractor. | ||
| */ | ||
| public get config(): IExtractorConfig { |
There was a problem hiding this comment.
Call this something other than config, because that implies that it's the same thing that got passed into the constructor. #Resolved
| private static _matchParent<T extends ts.Node>(node: ts.Node, parentKinds: ts.SyntaxKind[]): T | undefined { | ||
| let current: ts.Node | undefined = node; | ||
|
|
||
| let i: number = 0; |
There was a problem hiding this comment.
[](start = 7, length = 2)
two spaces #Resolved
| let current: ts.Node | undefined = node; | ||
|
|
||
| let i: number = 0; | ||
| while (true) { // tslint:disable-line:no-constant-condition |
There was a problem hiding this comment.
while [](start = 4, length = 5)
See if you can make this into a normal for loop. #Resolved
| } | ||
| break; | ||
| } | ||
| } |
There was a problem hiding this comment.
Describe why this is necessary. #Pending
There was a problem hiding this comment.
Let's consider _modifySpan() a prototype for now. I need to get it wired up and see how it works for various real world inputs first, then I'll come back and rework this code. Some of the logic will be completely eliminated when we start processing *.d.ts inputs instead of *.ts.
In reply to: 152427693 [](ancestors = 152427693)
| // console.log(PrettyPrinter.dumpTree(declaration)); | ||
| // console.log('-------------------------------------'); | ||
| // console.log(declaration.getText()); | ||
| // console.log('====================================='); |
There was a problem hiding this comment.
Clean up all of this commented out code. #Resolved
There was a problem hiding this comment.
|
|
||
| const dtsFilename: string = path.resolve(this._absoluteRootFolder, | ||
| this._config.packageTypings.outputFolder, this._config.packageTypings.internalFilename); | ||
| this._logger.logVerbose(`Writing package typings: ${dtsFilename}`); |
There was a problem hiding this comment.
[](start = 6, length = 2)
Extra space. #Resolved
| moduleExport: boolean; | ||
| } | ||
|
|
||
| export default class PackageTypingsGenerator { |
There was a problem hiding this comment.
PackageTypingsGenerator [](start = 21, length = 23)
Where is the test for this class? #Resolved
There was a problem hiding this comment.
I've started moving the integration test projects into the "/build-tests" folder.
In reply to: 152429942 [](ancestors = 152429942)
| // Removes the leading underscore, for example: "_example" --> "example*" | ||
| // This causes internal definitions to sort alphabetically with regular definitions. | ||
| // The star is appended to preserve uniqueness, since "*" is not a legal identifier character. | ||
| this._sortKey = this.localName.substr(1) + ' '; |
There was a problem hiding this comment.
' ' [](start = 51, length = 3)
Is this the star you talked about in the comment? #Resolved
There was a problem hiding this comment.
…be used by DtsGenerator
interface Mixed extends A { m1: string; }
interface Mixed extends B { m2: string; }
class Mixed { }
- Added Span.dump()
…us spacing issues
…ons involving multiple nodes in the tree
…the Extractor API
…liminates this problem
79c6ac8 to
bf6a97f
Compare
…using a trivial build.js script
…eturn a nonzero exit code for a "--local" build; warnings should not fail the build in this scenario
This PR is the first set of work for a new feature where API Extractor will generate package typings. Suppose the compiler produces ./lib/index.d.ts with the entry point for the package. API Extractor will produce three additional files:
When publishing, the package.json file's
"typings"entry will be pointed to one of these three files, depending on the release type.This PR contains:
It's able to to generate a working ./dist/index-internal.d.ts for node-core-library, but is missing features required to handle more complicated libraries. That will be introduced in a separate PR.