Repository navigation
Adding custom external @types .d.ts files, ExternalApiHelper to create json files on external .d.ts - #52
Conversation
# Conflicts: # common/npm-shrinkwrap.json # common/temp_modules/rush-api-extractor/package.json # common/temp_modules/rush-gulp-core-build-karma/package.json # common/temp_modules/rush-gulp-core-build-mocha/package.json # common/temp_modules/rush-gulp-core-build-sass/package.json # common/temp_modules/rush-gulp-core-build-serve/package.json # common/temp_modules/rush-gulp-core-build-typescript/package.json # common/temp_modules/rush-gulp-core-build-webpack/package.json # common/temp_modules/rush-gulp-core-build/package.json # common/temp_modules/rush-node-library-build/package.json # common/temp_modules/rush-package-deps-hash/package.json # common/temp_modules/rush-web-library-build/package.json
…osoft/web-build-tools into dagaeta/external-api-helper
| // We need to wrap this class in a getter because it hasn't been compiled by the time this file is executed | ||
| const taskWrapper = {}; | ||
| Object.defineProperty(taskWrapper, "default", { | ||
| get: () => require('./lib/RunApiExtractorOnExternalApiTypes.js').default |
There was a problem hiding this comment.
Ian Clanton-Thuon (@iclanton) nickpape-msft The idea of ExternalApiHelper.generateApiJson() was to push all the complicated logic down into a TypeScript function that could be compiled as part of api-extractor, so that the gulpfile would just be a few simple lines that invoke it. This would eliminate the need for a weird wrapper that uses the gulpfile to compile part of its own code.
The one wrinkle is that api-extractor should not have a dependency on GulpTask, so you would need to solve that somehow. Is that doable?
| public executeTask(gulp: gulp.Gulp, completeCallback?: (result?: Object) => void): void { | ||
| let outputPath: string = path.join(this.buildConfig.rootPath, this.buildConfig.distFolder); | ||
| if (!fs.existsSync(outputPath)) { | ||
| fs.mkdirSync(outputPath); |
There was a problem hiding this comment.
If this is the last step of the build, surely the "dist" folder would already exist, right?
| import { GulpTask } from '@microsoft/gulp-core-build'; | ||
| import { ExternalApiHelper } from '@microsoft/api-extractor'; | ||
|
|
||
| const files: string[] = ['external-api-types/es6-collections/index.d.ts', |
There was a problem hiding this comment.
The top-level folders for our NPM packages are always standard roles such as "src", "temp", "typings", etc.
To solve this problem, maybe we coudl define a "resources" folder that would contain other build inputs that are not source code. So the path name would be something like:
./resources/external-types/es6-collections
| @@ -0,0 +1,111 @@ | |||
| // Type definitions for fetch API | |||
There was a problem hiding this comment.
At the top of this file, we should have a note like this:
"Typings based on DefinitelyTyped definitions from whatwg-fetch@1.2.3"
But delete all other source code comments, since we will be authoring our own original content.
Pete Gonzalez (octogonz)
left a comment
There was a problem hiding this comment.
See comments
| import Analyzer from './Analyzer'; | ||
| import ApiJsonGenerator from './generators/ApiJsonGenerator'; | ||
|
|
||
| export default class ExternalApiHelper { |
There was a problem hiding this comment.
Add some JSDoc explaining what this thing is, how it is used, etc.
|
|
||
| export default class ExternalApiHelper { | ||
|
|
||
| public static generateApiJson(rootDir: string, libFolder: string, externalPackageFilePath: string): void { |
There was a problem hiding this comment.
Document these parameters. Mainly it would be helpful to have an example string for each parameter (e.g. is it a relative or absolute path, etc)
|
|
||
| // Typings based on DefinitelyTyped definitions from es6-collections@0.5.1 | ||
|
|
||
| /* tslint:disable: interface-name */ |
There was a problem hiding this comment.
We aren't running tslint, so we don't need these directives
Pete Gonzalez (octogonz)
left a comment
There was a problem hiding this comment.
Approved with comments
Adding custom external @types .d.ts files, ExternalApiHelper to create json files on external .d.ts
…elper Adding custom external @types .d.ts files, ExternalApiHelper to create json files on external .d.ts
No description provided.