@progress/kendo-typescript-tasks 10.0.22-dev.0 → 10.0.22-ng12.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api.config.js CHANGED
@@ -1,22 +1,8 @@
1
- const os = require('os');
2
1
  const path = require('path');
3
2
 
4
- const jsonPath = path.join(os.tmpdir(), `api-${process.pid}.json`);
3
+ const jsonPath = path.resolve('./api.json');
5
4
  const typedoc = {
6
- // TypeScript options
7
- module: 'commonjs',
8
- target: 'es6',
9
- types: [],
10
- experimentalDecorators: true,
11
- jsx: 'react', // support for tsx files
12
-
13
- // Output options
14
- json: jsonPath,
15
-
16
- // Typedoc options
17
- excludeExternals: true,
18
- ignoreCompilerErrors: false,
19
- includeDeclarations: true
5
+ excludeExternals: false
20
6
  };
21
7
 
22
8
  module.exports = {
package/api.js CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  const execSync = require('child_process').execSync;
4
4
  const path = require('path');
5
- const typedoc = require('gulp-typedoc');
6
5
  const { merge } = require('lodash');
6
+ const typedoc = require('typedoc');
7
+ const glob = require('glob');
7
8
 
8
9
  const api = require('./src/api/generator.js');
9
10
  const apiConfig = require('./api.config.js');
@@ -12,15 +13,34 @@ module.exports = (gulp, userConfig) => {
12
13
  const series = gulp.series;
13
14
 
14
15
  const config = merge({}, apiConfig, userConfig);
15
- const DECLARATIONS = ["typings/index.d.ts", "node_modules/@types/core-js/index.d.ts"];
16
16
 
17
- gulp.task('api-json', () => {
18
- return gulp.src(["src/**/*.{ts,tsx}", ...DECLARATIONS, ...(config.externalApi || [])], { "allowEmpty": true })
19
- .pipe(typedoc(config.typedoc));
17
+ gulp.task('api-json', async(done) => {
18
+ const entryPoints = [
19
+ ...glob.sync("src/**/*.{ts,tsx}"),
20
+ ...(config.externalApi || [])
21
+ ];
22
+
23
+ const app = new typedoc.Application();
24
+ app.options.addReader(new typedoc.TSConfigReader());
25
+ app.bootstrap({ ...config.typedoc, entryPoints });
26
+
27
+ const project = app.convert();
28
+ if (!project) {
29
+ done(new Error('Unable to initialize TypeDoc.'));
30
+ return;
31
+ }
32
+
33
+ await app.generateJson(project, apiConfig.jsonPath);
34
+ if (app.logger.hasErrors()) {
35
+ done(new Error('Unable to generate API reference, see messages above.'));
36
+ return;
37
+ }
38
+
39
+ done();
20
40
  });
21
41
 
22
42
  gulp.task('api-clean', (done) => {
23
- execSync(`rm -rf docs/api`, {stdio:[0,1,2]});
43
+ execSync(`rm -rf docs/api`, { stdio: [ 0,1,2 ] });
24
44
  done();
25
45
  });
26
46
 
@@ -31,7 +51,7 @@ module.exports = (gulp, userConfig) => {
31
51
  }));
32
52
 
33
53
  gulp.task('api-check', series('api', (done) => {
34
- execSync(`git diff --exit-code --color -- ${config.outPath}`,{stdio:[0,1,2]});
54
+ execSync(`git diff --exit-code --color -- ${config.outPath}`,{ stdio: [ 0,1,2 ] });
35
55
  done();
36
56
  }));
37
57
  };
package/gulp-tasks.js CHANGED
@@ -3,11 +3,10 @@
3
3
  const del = require('del');
4
4
  const childProcess = require('child_process');
5
5
  const path = require('path');
6
- const gulpTsLint = require('gulp-tslint');
7
- const tslint = require('tslint');
8
6
 
9
7
  const apiTasks = require('./api.js');
10
8
  const commonTasks = require('@progress/kendo-common-tasks');
9
+ const linter = require('./src/linter');
11
10
 
12
11
  const webpackConfig = require('./webpack.config.js');
13
12
  const tscPath = path.join(process.cwd(), 'node_modules', '.bin', 'tsc');
@@ -27,39 +26,25 @@ module.exports = (gulp, libraryName, compilerPath, options, webpackConfigPath) =
27
26
 
28
27
  childProcess.exec(`${cmd} -p ${tsConfigPath}`, err => {
29
28
  del.sync([ 'src/**/*.ngfactory.*', 'src/**/*.ngsummary.*',
30
- 'dist/**/*.ngfactory.*', 'dist/**/*.ngsummary.*' ]);
31
- done(err)
29
+ 'dist/**/*.ngfactory.*', 'dist/**/*.ngsummary.*' ]);
30
+ done(err);
32
31
  });
33
32
  };
34
33
 
35
34
  gulp.task('check-compilation', (done) => {
36
- childProcess.execSync(`${tscPath} --noEmit`, {stdio:[0,1,2]});
37
- done()
35
+ childProcess.execSync(`${tscPath} --noEmit`, { stdio: [ 0,1,2 ] });
36
+ done();
38
37
  });
39
38
 
40
- gulp.task('lint', series('check-compilation', (done) => {
41
- const program = tslint.Linter.createProgram('./tsconfig.json', '.');
39
+ gulp.task('lint', series(
40
+ 'check-compilation',
41
+ linter([ 'src/**/*.{ts,tsx}', 'test/**/*.{ts,tsx}', 'e2e/**/*.{ts,tsx}' ])
42
+ ));
42
43
 
43
- return gulp.src([ 'src/**/*.{ts,tsx}', 'test/**/*.{ts,tsx}', 'e2e/**/*.{ts,tsx}' ])
44
- .pipe(gulpTsLint({
45
- program: program,
46
- formatter: 'verbose'
47
- }))
48
- .pipe(gulpTsLint.report());
44
+ gulp.task('lint-docs', linter([ 'docs/examples/**/*.{ts,tsx}' ], {
45
+ overrideConfigFile: '.eslintrc.docs.json'
49
46
  }));
50
47
 
51
- gulp.task('lint-docs', () => {
52
- const program = tslint.Linter.createProgram('./tsconfig.docs.json', '.');
53
-
54
- return gulp.src([ 'docs/examples/**/*.{ts,tsx}'])
55
- .pipe(gulpTsLint({
56
- formatter: 'prose',
57
- program: program,
58
- configuration: './tslint.docs.json'
59
- }))
60
- .pipe(gulpTsLint.report());
61
- });
62
-
63
48
  gulp.task('start', (done) => {
64
49
  const webpackPort = 8888;
65
50
  const host = listenAddress;
@@ -68,10 +53,10 @@ module.exports = (gulp, libraryName, compilerPath, options, webpackConfigPath) =
68
53
 
69
54
  const config = Object.assign({}, webpackConfig.dev);
70
55
  config.resolve = Object.assign({}, config.resolve, {
71
- alias: {
72
- [packageInfo.name]: process.cwd() + '/src/main'
73
- },
74
- modules: [ path.join(process.cwd(), 'node_modules') ]
56
+ alias: {
57
+ [packageInfo.name]: process.cwd() + '/src/main'
58
+ },
59
+ modules: [ path.join(process.cwd(), 'node_modules') ]
75
60
  });
76
61
 
77
62
  const webpack = commonTasks.webpack(config);
@@ -86,7 +71,7 @@ module.exports = (gulp, libraryName, compilerPath, options, webpackConfigPath) =
86
71
  server.listen(webpackPort, host, err => {
87
72
  if (err) {
88
73
  done();
89
- throw new $.util.PluginError('webpack-dev-server', err);
74
+ throw new $.util.PluginError('webpack-dev-server', err); // eslint-disable-line no-undef
90
75
  }
91
76
  });
92
77
  });
@@ -95,5 +80,5 @@ module.exports = (gulp, libraryName, compilerPath, options, webpackConfigPath) =
95
80
  gulp.task('build-es-bundle', compile('tsconfig.es.json'));
96
81
  gulp.task('build-es2015-bundle', compile('tsconfig.es2015.json'));
97
82
  gulp.task('build-npm-bundle', compile('tsconfig.npm.json'));
98
- gulp.task('build-package', series.apply(null, ['build-npm-bundle', 'build-es-bundle', 'build-cdn', 'build-systemjs-bundle']));
99
- };
83
+ gulp.task('build-package', series([ 'build-npm-bundle', 'build-es-bundle', 'build-cdn', 'build-systemjs-bundle' ]));
84
+ };
package/gulpfile.js CHANGED
@@ -3,13 +3,10 @@
3
3
  const gulp = require('gulp');
4
4
  const jasmine = require('gulp-jasmine');
5
5
 
6
- // kendo-common-task linter is ancient, skip it for now
7
- gulp.task('lint', (done) => done());
8
-
9
6
  gulp.task('test', () =>
10
7
  gulp.src('test/**/*.js')
11
- .pipe(jasmine({
12
- includeStackTrace: true
13
- }))
8
+ .pipe(jasmine({
9
+ includeStackTrace: true
10
+ }))
14
11
  );
15
12
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@progress/kendo-typescript-tasks",
3
3
  "description": "Kendo UI TypeScript package gulp tasks",
4
4
  "main": "gulp-tasks.js",
5
- "version": "10.0.22-dev.0+312a5e9",
5
+ "version": "10.0.22-ng12.72+c683c3c",
6
6
  "author": "Telerik",
7
7
  "license": "Apache-2.0",
8
8
  "scripts": {
@@ -15,29 +15,31 @@
15
15
  "API Generation"
16
16
  ],
17
17
  "peerDependencies": {
18
- "typescript": "^3.4.5"
18
+ "typescript": "^4.3.4"
19
19
  },
20
20
  "dependencies": {
21
- "@progress/kendo-common-tasks": "7.9.5-dev.3+312a5e9",
22
- "core-js": "^2.2.2",
21
+ "@progress/kendo-common-tasks": "7.9.5-ng12.76+c683c3c",
22
+ "@typescript-eslint/eslint-plugin": "4.28.2",
23
+ "@typescript-eslint/parser": "4.28.2",
24
+ "core-js": "^3.18.0",
23
25
  "del": "2.2.2",
26
+ "eslint": "7.32.0",
27
+ "eslint-plugin-import": "2.25.2",
28
+ "eslint-plugin-rxjs": "3.3.7",
29
+ "glob": "^7.2.0",
24
30
  "gulp": "^4.0.0",
25
31
  "gulp-add-src": "^1.0.0",
26
- "gulp-tslint": "^8.0.0",
27
- "gulp-typedoc": "~2.2.2",
28
32
  "handlebars": "^4.0.5",
29
33
  "highlight.js": "9.14.2",
30
34
  "lodash": "^4.6.0",
31
35
  "mkdirp": "^0.5.0",
32
36
  "source-map-loader": "^0.1.5",
33
37
  "ts-loader": "4.1.0",
34
- "tslint": "^5.0.0",
35
- "tslint-defocus": "^2.0.6",
36
- "typedoc": "0.15.0"
38
+ "typedoc": "~0.22.5"
37
39
  },
38
40
  "devDependencies": {
39
41
  "gulp-jasmine": "^2.4.2",
40
- "typescript": "~3.4.5"
42
+ "typescript": "~4.3.4"
41
43
  },
42
44
  "repository": {
43
45
  "type": "git",
@@ -46,5 +48,5 @@
46
48
  "publishConfig": {
47
49
  "access": "public"
48
50
  },
49
- "gitHead": "312a5e97951ec3e69926d909e573bf5aafff222f"
51
+ "gitHead": "c683c3cf53173e65898d3a40a13a2c6654e98238"
50
52
  }
package/spec-bundle.js CHANGED
@@ -31,5 +31,5 @@ function requireAll(requireContext) {
31
31
  return requireContext.keys().map(requireContext);
32
32
  }
33
33
 
34
- var modules = requireAll(testContext);
34
+ let modules = requireAll(testContext); // eslint-disable-line no-unused-vars
35
35
  // requires and returns all modules that match
@@ -27,7 +27,9 @@ const commentTags = (comment, member) =>
27
27
  });
28
28
 
29
29
  const formatComment = (member, parentName, memberKind) => {
30
- const comment = member.comment;
30
+ const signatures = member.type?.declaration?.signatures;
31
+ const comment = member.comment || signatures && signatures[0]?.comment;
32
+
31
33
  if (!comment) {
32
34
  warn(member, parentName, memberKind);
33
35
 
@@ -22,12 +22,14 @@ const findDecorator = (decorators) => ((decorators || []).find(d =>
22
22
  const decoratorProp = (prop) => (decorators) => {
23
23
  const compDecorator = findDecorator(decorators);
24
24
 
25
- if (compDecorator) {
25
+ if (compDecorator) {
26
26
  const regExp = new RegExp(`${prop}:\\s?['"](.+?)['"]`);
27
27
  const match = compDecorator.arguments.obj.match(regExp);
28
28
 
29
29
  return match ? match[1] : undefined;
30
30
  }
31
+
32
+ return undefined;
31
33
  };
32
34
 
33
35
  const selector = decoratorProp('selector');
@@ -9,7 +9,7 @@ function enumValues(member) {
9
9
  comment: comment(child),
10
10
  name: child.name
11
11
  };
12
- })
12
+ });
13
13
  }
14
14
 
15
15
  const enumTemplate = template.compileFrom('enum-page.hbs');
@@ -60,7 +60,7 @@ const traverseElements = (elements, callback) => {
60
60
  const value = element[field];
61
61
  if (Array.isArray(value)) {
62
62
  traverseElements(value, callback);
63
- } else if (typeof value == 'object') {
63
+ } else if (typeof value === 'object' && value !== null) {
64
64
  traverseElements([ value ], callback);
65
65
  }
66
66
  }
@@ -71,7 +71,7 @@ const associateTypes = (elements, knownTypes) => {
71
71
  traverseElements(elements, element => {
72
72
  addTypeSlug(element, knownTypes);
73
73
  });
74
- }
74
+ };
75
75
 
76
76
  const normalizeUnionReferences = (element, members) => {
77
77
  if (element.kind === 'union') {
@@ -79,19 +79,17 @@ const normalizeUnionReferences = (element, members) => {
79
79
  for (let idx = types.length - 1; idx >= 0; idx--) {
80
80
  const type = types[idx];
81
81
  if (type.type === 'reference') {
82
- const unionReference = members.find((child) => {
83
- return child.name === type.name;
84
- });
82
+ const unionReference = members.find((child) => child.name === type.name);
85
83
 
86
84
  if (unionReference && unionReference.kind === 'union') {
87
85
  normalizeUnionReferences(unionReference, members);
88
86
  const toReplace = unionReference.type.types;
89
- types.splice.apply(types, [idx, 1].concat(toReplace));
87
+ types.splice.apply(types, [ idx, 1 ].concat(toReplace));
90
88
  }
91
89
  }
92
90
  }
93
91
  }
94
- }
92
+ };
95
93
 
96
94
  const normalizeMembers = (members) => {
97
95
  traverseElements(members, (element) => {
@@ -99,9 +97,7 @@ const normalizeMembers = (members) => {
99
97
 
100
98
  if (!element.comment && element.implementationOf) {
101
99
  const interfaceName = element.implementationOf.name.split('.')[0];
102
- const interfaceOptions = members.find((child) => {
103
- return child.name === interfaceName;
104
- });
100
+ const interfaceOptions = members.find((child) => child.name === interfaceName);
105
101
 
106
102
  if (interfaceOptions) {
107
103
  const baseOption = interfaceOptions.children.find(child => child.name === element.name);
@@ -110,8 +106,13 @@ const normalizeMembers = (members) => {
110
106
  }
111
107
  }
112
108
  }
109
+
110
+ if (!element.comment && element.kindString === 'Accessor') {
111
+ const accessor = element.getSignature || element.setSignature || [];
112
+ element.comment = accessor[0].comment;
113
+ }
113
114
  });
114
- }
115
+ };
115
116
 
116
117
  const mergeComments = (root, src) => {
117
118
  if (!root.comment && src.comment) {
@@ -123,23 +124,20 @@ const mergeComments = (root, src) => {
123
124
  mergeComments(root[key], src[key]);
124
125
  }
125
126
  });
126
- }
127
-
128
- const moduleRoot = (moduleName, rootModules) => {
129
- return rootModules.includes(moduleName) ? moduleName :
130
- rootModules.find(rootModule => moduleName.indexOf(rootModule) > -1);
131
127
  };
132
128
 
129
+ const moduleRoot = (moduleName, rootModules) => (rootModules.includes(moduleName) ? moduleName :
130
+ rootModules.find(rootModule => moduleName.indexOf(rootModule) > -1));
131
+
133
132
  const moduleFullName = (moduleName, packageName, rootModules) => {
134
133
  const rootModule = moduleRoot(moduleName, rootModules);
135
134
  let fullName = packageName;
136
- if (rootModule)
137
- {
135
+ if (rootModule) {
138
136
  fullName += '_' + rootModule;
139
137
  }
140
138
 
141
139
  return fullName;
142
- }
140
+ };
143
141
 
144
142
  const extractMembers = (packageName, modules, config) => {
145
143
  const knownTypes = {};
@@ -148,8 +146,9 @@ const extractMembers = (packageName, modules, config) => {
148
146
 
149
147
  const models = nonEmptyModules.map(module => module
150
148
  .children
151
- .filter(child => child.flags.isExported)
149
+ .filter(child => child.kindString !== "Reference")
152
150
  .filter(child => child.name !== 'core')
151
+ .filter(child => !child.sources[0].fileName.includes('prosemirror'))
153
152
  .map(child => {
154
153
  const fullName = moduleFullName(module.name, packageName, rootModules);
155
154
 
@@ -182,7 +181,7 @@ const extractMembers = (packageName, modules, config) => {
182
181
  const members = utils.flatten(models)
183
182
  .sort(utils.nameComparer)
184
183
  .map(model => {
185
- associateTypes([model], knownTypes);
184
+ associateTypes([ model ], knownTypes);
186
185
  return model;
187
186
  });
188
187
 
@@ -195,7 +194,6 @@ const namespacesAsModules = data => {
195
194
  const modules = [];
196
195
  data.filter(moduleFilter).forEach(module => module
197
196
  .children
198
- .filter(child => child.flags.isExported)
199
197
  .filter(child => child.name !== 'core')
200
198
  .forEach(child => {
201
199
  if (child.kindString === 'Module' && child.children) {
@@ -227,6 +225,18 @@ const groupMembers = (members) => {
227
225
  return membersByModule;
228
226
  };
229
227
 
228
+ const packagePlatform = (packageInfo) => {
229
+ let platform = '';
230
+
231
+ if (/-angular-/.test(packageInfo.name)) {
232
+ platform = 'Angular';
233
+ } else if (/-react-/.test(packageInfo.name)) {
234
+ platform = 'React';
235
+ }
236
+
237
+ return platform;
238
+ };
239
+
230
240
  const generate = (done, config, packageInfo) => {
231
241
  const meta = require(config.jsonPath);
232
242
  const namespaces = namespacesAsModules(meta.children);
@@ -234,8 +244,7 @@ const generate = (done, config, packageInfo) => {
234
244
  const membersByModule = config.reorderModules ?
235
245
  config.reorderModules(groupMembers(members)) : groupMembers(members);
236
246
  const outPath = config.outPath;
237
- const platform = /-angular-/.test(packageInfo.name) ? 'Angular' :
238
- /-react-/.test(packageInfo.name) ? 'React' : '';
247
+ const platform = packagePlatform(packageInfo);
239
248
  const info = Object.assign({ platform }, packageInfo['@progress']);
240
249
 
241
250
  writeFile(`${outPath}/index.md`, indexPage(packageInfo.name, membersByModule, info));
@@ -2,16 +2,19 @@
2
2
 
3
3
  const comment = require('./comment');
4
4
  const isPublic = require('./is-public');
5
- const isInput = require('./is-input');
6
5
  const types = require('./type-utils');
7
6
  const utils = require('./utils');
8
7
 
9
8
  const isConstructor = (prop) =>
10
9
  prop.kindString && prop.kindString === 'Constructor' && isPublic(prop);
11
10
 
12
- const mapConstructors = (member) =>
13
- utils.flatten(member.children.filter(isConstructor).map(ctr => {
14
- const name = ctr.name;
11
+ const mapConstructors = (member) => {
12
+ if (member.decorators && member.decorators.find(d => d.name === 'NgModule')) {
13
+ // Ignore NgModule constructors
14
+ return [];
15
+ }
16
+
17
+ return utils.flatten(member.children.filter(isConstructor).map(ctr => {
15
18
  const source = `${member.name}.constructor`;
16
19
 
17
20
  return ctr.signatures.map((signature) => ({
@@ -21,6 +24,7 @@ const mapConstructors = (member) =>
21
24
  params: types.params(signature, source)
22
25
  }));
23
26
  }));
27
+ };
24
28
 
25
29
  module.exports = mapConstructors;
26
30
 
@@ -15,12 +15,13 @@ const defaultValue = prop => {
15
15
  return text && ` (default: ${text.trim()})`;
16
16
  };
17
17
 
18
- const accessor = signature => Array.isArray(signature) ? signature[0] : signature;
18
+ const accessor = signature => (Array.isArray(signature) ? signature[0] : signature);
19
19
 
20
20
  const isProp = (prop) => isPublic(prop) && !isConstructor(prop) && !isMethod(prop);
21
21
  const mapProps = (children, parentName) =>
22
22
  children.filter(isProp).map(prop => {
23
23
  let type;
24
+ let commentProp = prop;
24
25
  if (prop.type) {
25
26
  type = types.typeString(prop);
26
27
  } else if (prop.kindString === 'Accessor') {
@@ -28,12 +29,13 @@ const mapProps = (children, parentName) =>
28
29
  const setter = prop.setSignature;
29
30
 
30
31
  // Fingers crossed
31
- type = types.typeString(getter ?
32
- accessor(getter) :
33
- accessor(setter).parameters[0]
32
+ type = types.typeString(setter ?
33
+ accessor(setter).parameters[0] :
34
+ accessor(getter)
34
35
  );
35
36
  } else if (prop.kindString === 'Method') {
36
37
  type = types.callType(prop.signatures[0]);
38
+ commentProp = prop.signatures[0];
37
39
  }
38
40
 
39
41
  let name = prop.name;
@@ -53,7 +55,7 @@ const mapProps = (children, parentName) =>
53
55
  name: name,
54
56
  type: type,
55
57
  defaultValue: defaultValue(prop),
56
- comment: comment(prop, parentName)
58
+ comment: comment(commentProp, parentName)
57
59
  };
58
60
  });
59
61
 
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  const path = require('path');
4
- const template = require('./template-utils');
5
4
  const componentPage = require('./component-page');
6
5
  const constantPage = require('./constant-page');
7
6
  const classPage = require('./class-page');
@@ -16,7 +16,7 @@ const returnType = (definition, parentName) => {
16
16
  if (!comment && definition.type.name !== 'void') {
17
17
  let source = `${definition.name}`;
18
18
  if (parentName) {
19
- source = `${parentName } - ${source}`;
19
+ source = `${parentName } - ${source}`;
20
20
  }
21
21
  utils.warn('Undocumented return type', source);
22
22
  }
@@ -8,7 +8,10 @@ hbs.registerHelper('capitalize',
8
8
  s => s.slice(0,1).toUpperCase() + s.slice(1));
9
9
 
10
10
  hbs.registerHelper('contains',
11
- (s, chars, options) => s.includes(chars) ? options.fn(s) : options.inverse(s));
11
+ (s, chars, options) => (s.includes(chars) ? options.fn(s) : options.inverse(s)));
12
+
13
+ hbs.registerHelper('equals',
14
+ (s, comparer, options) => (s === comparer ? options.fn(s) : options.inverse(s)));
12
15
 
13
16
  const readLocal = (src) =>
14
17
  fs.readFileSync(path.join(__dirname, src), { encoding: 'utf-8' });
@@ -5,7 +5,7 @@ const comment = require('./comment');
5
5
  const unionTypes = (member) =>
6
6
  member.type.types.map(type => {
7
7
  switch (type.type) {
8
- case 'stringLiteral':
8
+ case 'literal':
9
9
  return `"${type.value}"`;
10
10
  default:
11
11
  return typeString({ type });
@@ -92,6 +92,10 @@ const INTERSECTION = ' [intersected](https://www.typescriptlang.org/docs/handboo
92
92
  const singleTypeString = (type) => {
93
93
  let suffix = '';
94
94
 
95
+ if (type.type === 'literal') {
96
+ return type.value;
97
+ }
98
+
95
99
  if (type.type === 'intersection') {
96
100
  return unionTypes({ type }).join(INTERSECTION);
97
101
  }
@@ -100,7 +104,7 @@ const singleTypeString = (type) => {
100
104
  const decl = type.declaration;
101
105
  if (decl.signatures) {
102
106
  const sig = decl.signatures[0];
103
- if (decl.name === '__type' && sig.name === '__call') {
107
+ if (decl.name === '__type' && sig.kindString === 'Call signature') {
104
108
  return callType(sig);
105
109
  }
106
110
  } else if (decl.indexSignature) {
@@ -115,13 +119,13 @@ const singleTypeString = (type) => {
115
119
  }
116
120
  }
117
121
 
122
+ if (type.type === 'array') {
123
+ return `${singleTypeString(type.elementType)}[]`;
124
+ }
125
+
118
126
  if (type.typeArguments) {
119
127
  suffix = `<${singleTypeString(type.typeArguments[0])}>`;
120
128
  }
121
-
122
- if (type.type === 'array') {
123
- suffix += '[]';
124
- }
125
129
 
126
130
  const name = typeName(type);
127
131
 
@@ -135,8 +139,8 @@ const typeString = (prop) => {
135
139
  return unionTypes(prop).join(' | ');
136
140
  }
137
141
 
138
- if (type.type === 'stringLiteral') {
139
- return `'${type.value}'`;
142
+ if (type.type === 'literal') {
143
+ return `"${type.value}"`;
140
144
  }
141
145
 
142
146
  return singleTypeString(prop.type);
@@ -153,7 +157,7 @@ const fullName = (member) => {
153
157
  }
154
158
 
155
159
  return member.name + suffix;
156
- }
160
+ };
157
161
 
158
162
  module.exports = {
159
163
  callSignature: callSignature,
@@ -6,6 +6,7 @@
6
6
  `type` {{name}} =
7
7
  {{~#each types~}}
8
8
  {{~#contains this 'slug'}} {{this}}
9
+ {{~else equals this '"null"'}} `null`
9
10
  {{~else contains this '"'}} {{this}}
10
11
  {{~else}} `{{this}}`
11
12
  {{~/contains~}}
package/src/api/utils.js CHANGED
@@ -9,15 +9,15 @@ const not = predicate => member => !predicate(member);
9
9
 
10
10
  const ignore = predicate => props => (props || []).filter(predicate);
11
11
 
12
- const hasProp = prop => obj => !!obj[prop];
12
+ const hasProp = prop => obj => Boolean(obj[prop]);
13
13
 
14
14
  const groupBy = (predicate, list) =>
15
15
  list.reduce((acc, item) => {
16
- const field = predicate(item);
17
- acc[field] = acc[field] || [];
18
- acc[field].push(item);
19
- return acc;
20
- }, {})
16
+ const field = predicate(item);
17
+ acc[field] = acc[field] || [];
18
+ acc[field].push(item);
19
+ return acc;
20
+ }, {});
21
21
 
22
22
  const WARNINGS = [];
23
23
  const warn = (type, text) => {
package/src/linter.js ADDED
@@ -0,0 +1,18 @@
1
+ const { ESLint } = require('eslint');
2
+
3
+ const linter = (files, options = {}) => async function lint(done) {
4
+ const eslint = new ESLint(options);
5
+ const results = await eslint.lintFiles(files);
6
+ const formatter = await eslint.loadFormatter('stylish');
7
+ const errors = ESLint.getErrorResults(results);
8
+ const resultText = formatter.format(results);
9
+ console.log(resultText);
10
+
11
+ if (errors.length > 0) {
12
+ done(new Error('Lint failed.'));
13
+ } else {
14
+ done();
15
+ }
16
+ };
17
+
18
+ module.exports = linter;
package/stub-loader.js CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module.exports = function() {
3
- return '{}';
3
+ return '{}';
4
4
  };
package/test/api.js CHANGED
@@ -51,7 +51,7 @@ describe('API generation', () => {
51
51
 
52
52
  describe('for modules', () => {
53
53
  const pkg = require('./package.json');
54
- const members = generator.extractMembers(pkg.name, pkg.children, { modules: ['module1'] });
54
+ const members = generator.extractMembers(pkg.name, pkg.children, { modules: [ 'module1' ] });
55
55
 
56
56
  it('adds module to slug', () => {
57
57
  expect(members[0].slug).toEqual('api_package-name_module1_foo');
@@ -170,6 +170,12 @@ describe('API generation', () => {
170
170
  const page = unionPage(intersectionData);
171
171
  expect(page).toContain('ColumnSortSettings [intersected](https://www.typescriptlang.org/docs/handbook/advanced-types.html#intersection-types) with { mode?: "single" | "multiple"; }');
172
172
  });
173
+
174
+ it('formats values conatining or equaling "null"', () => {
175
+ const unionData = require('./type-union-operators.json');
176
+ const page = unionPage(unionData);
177
+ expect(page).toContain('`type` FilterOperator = "gt" | "gte" | "isnull" | "isnotnull" | `null`');
178
+ });
173
179
  });
174
180
 
175
181
  describe('for components', () => {
@@ -325,22 +331,22 @@ describe('API generation', () => {
325
331
  describe('index', () => {
326
332
  const page = indexPage('foo/bar', {
327
333
  '': {
328
- 'Function': [{
334
+ 'Function': [ {
329
335
  'slug': 'root-f',
330
336
  'name': 'root-f'
331
- }]
337
+ } ]
332
338
  },
333
339
  'a': {
334
- 'Function': [{
340
+ 'Function': [ {
335
341
  'slug': 'a-f',
336
342
  'name': 'a-f'
337
- }]
343
+ } ]
338
344
  },
339
345
  'b': {
340
- 'Function': [{
346
+ 'Function': [ {
341
347
  'slug': 'b-f',
342
348
  'name': 'b-f'
343
- }]
349
+ } ]
344
350
  }
345
351
  }, {
346
352
  friendlyName: 'Foo',
@@ -348,7 +354,7 @@ describe('API generation', () => {
348
354
  });
349
355
 
350
356
  const assertModule = name => {
351
- expect(new RegExp(`<h2 class=\"module-name\">\\s*${name}\\s*<\\/h2>`).test(page)).toBeTruthy();
357
+ expect(new RegExp(`<h2 class="module-name">\\s*${name}\\s*<\\/h2>`).test(page)).toBeTruthy();
352
358
  };
353
359
 
354
360
  it('renders default group', () => {
@@ -46,11 +46,11 @@
46
46
  "type": "union",
47
47
  "types": [
48
48
  {
49
- "type": "stringLiteral",
49
+ "type": "literal",
50
50
  "value": "single"
51
51
  },
52
52
  {
53
- "type": "stringLiteral",
53
+ "type": "literal",
54
54
  "value": "multiple"
55
55
  }
56
56
  ]
@@ -0,0 +1,42 @@
1
+ {
2
+ "id": 416,
3
+ "name": "FilterOperator",
4
+ "kind": 4194304,
5
+ "kindString": "Type alias",
6
+ "flags": {},
7
+ "comment": {
8
+ "shortText": "Represents the FilterOperator type."
9
+ },
10
+ "sources": [
11
+ {
12
+ "fileName": "src/model/filter-expression.ts",
13
+ "line": 5,
14
+ "character": 12
15
+ }
16
+ ],
17
+ "type": {
18
+ "type": "union",
19
+ "types": [
20
+ {
21
+ "type": "literal",
22
+ "value": "gt"
23
+ },
24
+ {
25
+ "type": "literal",
26
+ "value": "gte"
27
+ },
28
+ {
29
+ "type": "literal",
30
+ "value": "isnull"
31
+ },
32
+ {
33
+ "type": "literal",
34
+ "value": "isnotnull"
35
+ },
36
+ {
37
+ "type": "literal",
38
+ "value": null
39
+ }
40
+ ]
41
+ }
42
+ }
@@ -52,11 +52,11 @@
52
52
  "type": "union",
53
53
  "types": [
54
54
  {
55
- "type": "stringLiteral",
55
+ "type": "literal",
56
56
  "value": "single"
57
57
  },
58
58
  {
59
- "type": "stringLiteral",
59
+ "type": "literal",
60
60
  "value": "multiple"
61
61
  }
62
62
  ]