Showing preview only (906K chars total). Download the full file or copy to clipboard to get everything.
Repository: buehler/node-typescript-parser
Branch: master
Commit: 3ba4306f11bb
Files: 137
Total size: 831.0 KB
Directory structure:
gitextract_bof42bjs/
├── .appveyor.yml
├── .gitignore
├── .npmignore
├── .npmrc
├── .travis.yml
├── LICENSE
├── README.md
├── config/
│ ├── tsconfig.base.json
│ └── tsconfig.build.json
├── jest.json
├── package.json
├── src/
│ ├── DeclarationIndex.ts
│ ├── Node.ts
│ ├── SymbolSpecifier.ts
│ ├── TypescriptParser.ts
│ ├── clonable/
│ │ └── Clonable.ts
│ ├── code-generators/
│ │ ├── TypescriptCodeGenerator.ts
│ │ ├── TypescriptGenerationOptions.ts
│ │ └── typescript-generators/
│ │ ├── accessorDeclaration.ts
│ │ ├── externalModuleImport.ts
│ │ ├── methodDeclaration.ts
│ │ ├── namedImport.ts
│ │ ├── namespaceImport.ts
│ │ ├── parameterDeclaration.ts
│ │ ├── propertyDeclaration.ts
│ │ ├── stringImport.ts
│ │ ├── symbolSpecifier.ts
│ │ └── variableDeclaration.ts
│ ├── declarations/
│ │ ├── AccessorDeclaration.ts
│ │ ├── ClassDeclaration.ts
│ │ ├── ConstructorDeclaration.ts
│ │ ├── Declaration.ts
│ │ ├── DeclarationInfo.ts
│ │ ├── DeclarationVisibility.ts
│ │ ├── DefaultDeclaration.ts
│ │ ├── EnumDeclaration.ts
│ │ ├── FunctionDeclaration.ts
│ │ ├── InterfaceDeclaration.ts
│ │ ├── MethodDeclaration.ts
│ │ ├── ModuleDeclaration.ts
│ │ ├── ParameterDeclaration.ts
│ │ ├── PropertyDeclaration.ts
│ │ ├── TypeAliasDeclaration.ts
│ │ ├── VariableDeclaration.ts
│ │ └── index.ts
│ ├── errors/
│ │ └── NotGeneratableYetError.ts
│ ├── exports/
│ │ ├── AllExport.ts
│ │ ├── AssignedExport.ts
│ │ ├── Export.ts
│ │ ├── NamedExport.ts
│ │ └── index.ts
│ ├── imports/
│ │ ├── ExternalModuleImport.ts
│ │ ├── Import.ts
│ │ ├── NamedImport.ts
│ │ ├── NamespaceImport.ts
│ │ ├── StringImport.ts
│ │ └── index.ts
│ ├── index.ts
│ ├── node-parser/
│ │ ├── class-parser.ts
│ │ ├── enum-parser.ts
│ │ ├── export-parser.ts
│ │ ├── function-parser.ts
│ │ ├── identifier-parser.ts
│ │ ├── import-parser.ts
│ │ ├── index.ts
│ │ ├── interface-parser.ts
│ │ ├── module-parser.ts
│ │ ├── parse-utilities.ts
│ │ ├── traverse-ast.ts
│ │ ├── type-alias-parser.ts
│ │ └── variable-parser.ts
│ ├── resources/
│ │ ├── File.ts
│ │ ├── Module.ts
│ │ ├── Namespace.ts
│ │ ├── Resource.ts
│ │ └── index.ts
│ ├── type-guards/
│ │ ├── TypescriptGuards.ts
│ │ └── TypescriptHeroGuards.ts
│ └── utilities/
│ ├── PathHelpers.ts
│ └── StringTemplate.ts
├── test/
│ ├── SpecificUsageCases.spec.ts
│ ├── TypescriptParser.spec.ts
│ ├── __snapshots__/
│ │ ├── SpecificUsageCases.spec.ts.snap
│ │ └── TypescriptParser.spec.ts.snap
│ ├── _workspace/
│ │ ├── .gitignore
│ │ ├── declaration-index/
│ │ │ ├── _index.ts
│ │ │ ├── another-classes.ts
│ │ │ ├── circular-export/
│ │ │ │ ├── circularExport1.ts
│ │ │ │ └── circularExport2.ts
│ │ │ ├── classes.ts
│ │ │ ├── exports/
│ │ │ │ ├── classes.ts
│ │ │ │ ├── export-alias.ts
│ │ │ │ ├── export-all.ts
│ │ │ │ ├── export-from-export.ts
│ │ │ │ └── export-some.ts
│ │ │ ├── helper-functions.ts
│ │ │ ├── index.ts
│ │ │ ├── myReactTemplate.tsx
│ │ │ ├── prototype-funcs.ts
│ │ │ ├── reactFile.tsx
│ │ │ └── specific-cases/
│ │ │ └── reindex-with-global-module-export/
│ │ │ └── classes.ts
│ │ ├── specific-usage-cases/
│ │ │ ├── i18next-destructure/
│ │ │ │ ├── destructure-my-component.tsx
│ │ │ │ └── import-my-component.tsx
│ │ │ └── reexport/
│ │ │ ├── reexport-default.ts
│ │ │ └── reexport-import.ts
│ │ └── typescript-parser/
│ │ ├── async.ts
│ │ ├── class.ts
│ │ ├── enum.ts
│ │ ├── exportsOnly.ts
│ │ ├── function.ts
│ │ ├── importsOnly.ts
│ │ ├── interface.ts
│ │ ├── javascript.js
│ │ ├── jsx.jsx
│ │ ├── module.ts
│ │ ├── parameters.ts
│ │ ├── specific-cases/
│ │ │ ├── 1.tsx
│ │ │ ├── 2.tsx
│ │ │ └── 3.tsx
│ │ ├── typeAlias.ts
│ │ ├── usagesOnly.ts
│ │ ├── usagesOnly.tsx
│ │ ├── variable.ts
│ │ └── webpack-bundle.js
│ ├── code-generators/
│ │ ├── TypescriptCodeGenerator.spec.ts
│ │ └── __snapshots__/
│ │ └── TypescriptCodeGenerator.spec.ts.snap
│ ├── declaration-index/
│ │ ├── DeclarationIndex.spec.ts
│ │ ├── __snapshots__/
│ │ │ └── DeclarationIndex.spec.ts.snap
│ │ └── specific-cases/
│ │ └── reindex-with-global-module/
│ │ ├── DeclarationIndex.reindex-with-global-module-export.spec.ts
│ │ └── __snapshots__/
│ │ └── DeclarationIndex.reindex-with-global-module-export.spec.ts.snap
│ ├── imports/
│ │ └── Imports.spec.ts
│ ├── parsing/
│ │ ├── Flags.spec.ts
│ │ └── __snapshots__/
│ │ └── Flags.spec.ts.snap
│ ├── testUtilities.ts
│ └── utilities/
│ └── PathHelpers.spec.ts
├── tsconfig.json
└── tslint.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .appveyor.yml
================================================
version: "{build} - {branch}"
skip_tags: true
skip_branch_with_pr: true
matrix:
fast_finish: true
environment:
matrix:
- nodejs_version: "10"
install:
- ps: Install-Product node $env:nodejs_version
- npm install
test_script:
- npm test
- npm install -g codecov
- codecov
- npm run build
build: off
================================================
FILE: .gitignore
================================================
# node
logs
*.log
npm-debug.log*
node_modules/
# testing
coverage/
# typescript
build/
================================================
FILE: .npmignore
================================================
# node
logs
*.log
npm-debug.log*
node_modules/
# testing
coverage/
test/
# typescript
src/
build/
tsconfig.json
config/
tslint.json
jest.json
.travis.yml
# docs
docs/
================================================
FILE: .npmrc
================================================
package-lock=false
================================================
FILE: .travis.yml
================================================
language: node_js
stages:
- name: test
if: tag IS blank
- name: build
if: tag IS blank
- name: deploy
if: branch = master AND type != pull_request
cache:
directories:
- node_modules
matrix:
fast_finish: true
notifications:
email: false
jobs:
include:
- stage: test
node_js: '10'
after_success:
- npm i -g codecov
- codecov
- stage: build
node_js: '10'
script:
- npm run build
- stage: deploy
node_js: '10'
script: npm run typedoc
deploy:
provider: pages
skip_cleanup: true
github_token: $GH_TOKEN
local_dir: ./docs
- stage: deploy
node_js: '10'
before_script: npm run build
script: npm run semantic-release
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2017 TypeScript Heroes
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# node typescript parser
This package is a TypeScript and ECMAScript parser. It uses the underlying typescript parser to generate
a more or less human readable AST out of .js or .ts files.
[](https://travis-ci.org/buehler/node-typescript-parser)
[](https://ci.appveyor.com/project/buehler/node-typescript-parser)
[](https://www.npmjs.com/package/typescript-parser)
[](https://codecov.io/gh/buehler/node-typescript-parser)
[](https://github.com/semantic-release/semantic-release)
[](https://greenkeeper.io/)
[](https://gitter.im/node-typescript-parser/Lobby)
## How to use
After you install the package via:
[](https://nodei.co/npm/typescript-parser/)
### [View Source Docs](https://buehler.github.io/node-typescript-parser/)
You can use the parser with:
```typescript
const parser = new TypescriptParser();
// either:
const parsed = await parser.parseSource(/* typescript source code as string */);
// or a filepath
const parsed = await parser.parseFile('/user/myfile.ts', 'workspace root');
```
You can also parse multiple files at ones.
To use the declaration index (which is basically a list of symbols for your files)
instantiate an index first and throw him some files.
After the parsing is done, you'll get an index with resolved
exports and declarations.
Keep in mind, that the index'll only contain exported declarations.
## Changelog
The changelog is generated by [semantic release](https://github.com/semantic-release/semantic-release) and is located under the
[release section](https://github.com/buehler/node-typescript-parser/releases).
## Licence
This software is licenced under the [MIT](LICENSE) licence.
================================================
FILE: config/tsconfig.base.json
================================================
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"removeComments": false,
"outDir": "../build",
"rootDir": "../src",
"declaration": true,
"sourceMap": false,
"importHelpers": true,
"strict": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"lib": [
"es2015",
"dom"
]
},
"include": [
"../src/**/*"
],
"exclude": [
"../node_modules",
"../build"
]
}
================================================
FILE: config/tsconfig.build.json
================================================
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "../"
}
}
================================================
FILE: jest.json
================================================
{
"collectCoverage": true,
"transform": {
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testURL": "http://localhost/",
"testMatch": [
"**/test/**/*.spec.ts"
],
"testPathIgnorePatterns": [
"/node_modules/",
"_workspace/"
],
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"json"
]
}
================================================
FILE: package.json
================================================
{
"name": "typescript-parser",
"version": "0.0.0-development",
"description": "Parser for typescript (and javascript) files, that compiles those files and generates a human understandable AST.",
"main": "index.js",
"typings": "index.d.ts",
"scripts": {
"build": "npm run clean && tsc -p ./config/tsconfig.build.json",
"clean": "del-cli ./build ./coverage",
"develop": "npm run clean && tsc -p .",
"lint": "tslint -c ./tslint.json -p ./config/tsconfig.build.json 'src/**/*.ts'",
"test": "npm run lint && npm run clean && jest -c ./jest.json",
"test:watch": "npm run clean && jest -c ./jest.json --watch --no-coverage",
"typedoc": "del-cli ./docs && typedoc --ignoreCompilerErrors --out ./docs --mode file --tsconfig ./config/tsconfig.build.json ./src/",
"semantic-release": "semantic-release"
},
"repository": {
"type": "git",
"url": "https://github.com/TypeScript-Heroes/node-typescript-parser.git"
},
"keywords": [
"typescript",
"parser",
"AST",
"parsing"
],
"author": "Christoph Bühler <christoph.buehler@bluewin.ch>",
"license": "MIT",
"bugs": {
"url": "https://github.com/TypeScript-Heroes/node-typescript-parser/issues"
},
"homepage": "https://github.com/TypeScript-Heroes/node-typescript-parser#readme",
"devDependencies": {
"@smartive/tslint-config": "^4.0.0",
"@types/jest": "^23.3.1",
"@types/lodash-es": "^4.17.1",
"@types/mock-fs": "^3.6.30",
"@types/node": "^10.9.4",
"del-cli": "^1.1.0",
"jest": "^23.5.0",
"mock-fs": "^4.6.0",
"semantic-release": "^15.9.12",
"ts-jest": "^23.1.4",
"tslint": "^5.11.0",
"tsutils": "^3.0.0",
"typedoc": "^0.12.0"
},
"dependencies": {
"lodash": "^4.17.10",
"lodash-es": "^4.17.10",
"tslib": "^1.9.3",
"typescript": "^3.0.3"
}
}
================================================
FILE: src/DeclarationIndex.ts
================================================
import { difference, differenceWith, intersection, isEqual } from 'lodash';
import { join, normalize, relative, resolve } from 'path';
import { DeclarationInfo } from './declarations/DeclarationInfo';
import { ModuleDeclaration } from './declarations/ModuleDeclaration';
import { AllExport } from './exports/AllExport';
import { AssignedExport } from './exports/AssignedExport';
import { NamedExport } from './exports/NamedExport';
import { File } from './resources/File';
import { Module } from './resources/Module';
import { Namespace } from './resources/Namespace';
import { Resource } from './resources/Resource';
import { isExportableDeclaration } from './type-guards/TypescriptHeroGuards';
import { TypescriptParser } from './TypescriptParser';
import { normalizeFilename, normalizePathUri, toPosix } from './utilities/PathHelpers';
/**
* Returns the name of the node folder. Is used as the library name for indexing.
* (e.g. ./node_modules/webpack returns webpack)
*
* @param {string} path
* @returns {string}
*/
function getNodeLibraryName(path: string): string {
const dirs = path.split(/\/|\\/);
const nodeIndex = dirs.indexOf('node_modules');
return normalizeFilename(dirs.slice(nodeIndex + 1).join('/'))
.replace(new RegExp(`/(index|${dirs[nodeIndex + 1]}|${dirs[dirs.length - 2]})$`), '');
}
/**
* Helper type to index all possible resources of the current workspace.
*/
type Resources = { [name: string]: Resource };
/**
* IndexDelta type, is calculated by the declaration index to give an overview, what has changed in the index.
* Returns a list of deleted declarations, newly added declarations (with the corresponding infos) and
* which declarations have been updated (with all declarations under that name).
*/
export type IndexDelta = {
added: { [declaration: string]: DeclarationInfo[] };
updated: { [declaration: string]: DeclarationInfo[] };
deleted: string[];
};
/**
* Interface for file changes. Contains lists of file uri's to the specific action.
*
* @export
* @interface FileChanges
*/
export interface FileChanges {
created: string[];
updated: string[];
deleted: string[];
}
/**
* Global index of declarations. Contains declarations and origins.
* Provides reverse index for search and declaration info for imports.
*
* @export
* @class DeclarationIndex
*/
export class DeclarationIndex {
private building: boolean = false;
/**
* Hash of parsed resources. Contains all parsed files / namespaces / declarations
* of the current workspace.
*
* @private
* @type {Resources}
* @memberof DeclarationIndex
*/
private parsedResources: Resources = Object.create(null);
/**
* Declaration index. Reverse index from a name to many declarations assotiated to the name.
*
* @private
* @type {({ [declaration: string]: DeclarationInfo[] } | undefined)}
* @memberof DeclarationIndex
*/
private _index: { [declaration: string]: DeclarationInfo[] } | undefined;
/**
* Indicator if the first index was loaded and calculated or not.
*
* @readonly
* @type {boolean}
* @memberof DeclarationIndex
*/
public get indexReady(): boolean {
return this._index !== undefined; // && this._indexWithBarrels !== undefined;
}
/**
* Reverse index of the declarations.
*
* @readonly
* @type {({ [declaration: string]: DeclarationInfo[] } | undefined)}
* @memberof DeclarationIndex
*/
public get index(): { [declaration: string]: DeclarationInfo[] } | undefined {
return this._index;
}
/**
* List of all declaration information. Contains the typescript declaration and the
* "from" information (from where the symbol is imported).
*
* @readonly
* @type {DeclarationInfo[]}
* @memberof DeclarationIndex
*/
public get declarationInfos(): DeclarationInfo[] {
return Object
.keys(this.index!)
.sort()
.reduce((all, key) => all.concat(this.index![key]), <DeclarationInfo[]>[]);
}
constructor(private parser: TypescriptParser, private rootPath: string) { }
/**
* Calculates the differences between two indices. Calculates removed, added and updated declarations.
* The updated declarations are calculated and all declarations that the new index contains are inserted in the list.
*
* @static
* @param {{ [declaration: string]: DeclarationInfo[] }} oldIndex
* @param {{ [declaration: string]: DeclarationInfo[] }} newIndex
* @returns {IndexDelta}
* @memberof DeclarationIndex
*/
public static calculateIndexDelta(
oldIndex: { [declaration: string]: DeclarationInfo[] },
newIndex: { [declaration: string]: DeclarationInfo[] },
): IndexDelta {
const oldKeys = Object.keys(oldIndex);
const newKeys = Object.keys(newIndex);
return {
added: difference(newKeys, oldKeys).reduce(
(obj, currentKey) => {
obj[currentKey] = newIndex[currentKey];
return obj;
},
{} as { [declaration: string]: DeclarationInfo[] },
),
updated: intersection(oldKeys, newKeys).reduce(
(obj, currentKey) => {
const old = oldIndex[currentKey];
const neu = newIndex[currentKey];
if (differenceWith(neu, old, isEqual).length > 0 || differenceWith(old, neu, isEqual).length > 0) {
obj[currentKey] = neu;
}
return obj;
},
{} as { [declaration: string]: DeclarationInfo[] },
),
deleted: difference(oldKeys, newKeys),
};
}
/**
* Resets the whole index. Does delete everything. Period.
* Is useful for unit testing or similar things.
*
* @memberof DeclarationIndex
*/
public reset(): void {
this.parsedResources = Object.create(null);
this._index = undefined;
}
/**
* Tells the index to build a new index.
* Can be canceled with a cancellationToken.
*
* @param {string[]} filePathes
* @returns {Promise<void>}
*
* @memberof DeclarationIndex
*/
public async buildIndex(filePathes: string[]): Promise<void> {
if (this.building) {
return;
}
try {
this.building = true;
const parsed = await this.parser.parseFiles(filePathes, this.rootPath);
this.parsedResources = await this.parseResources(parsed);
this._index = await this.createIndex(this.parsedResources);
} catch (e) {
throw e;
} finally {
this.building = false;
}
}
/**
* Is called when file events happen. Does reindex for the changed files and creates a new index.
* Returns the differences for the new index.
*
* @param {FileEvent[]} changes
* @returns {Promise<IndexDelta>}
*
* @memberof DeclarationIndex
*/
public async reindexForChanges(changes: FileChanges): Promise<IndexDelta> {
const rebuildResources: string[] = [];
const removeResources: string[] = [];
const rebuildFiles: string[] = [];
for (const change of changes.deleted) {
const filePath = normalizePathUri(change);
const resource = '/' + normalizeFilename(relative(this.rootPath, filePath));
if (removeResources.indexOf(resource) < 0) {
removeResources.push(resource);
}
for (const file of this.getExportedResources(resource)) {
if (rebuildFiles.indexOf(file) < 0) {
rebuildFiles.push(file);
}
}
}
for (const change of (changes.created || []).concat(changes.updated)) {
const filePath = normalizePathUri(change);
const resource = '/' + normalizeFilename(relative(this.rootPath, filePath));
if (rebuildResources.indexOf(resource) < 0) {
rebuildResources.push(resource);
}
if (rebuildFiles.indexOf(filePath) < 0) {
rebuildFiles.push(filePath);
}
for (const file of this.getExportedResources(resource)) {
if (rebuildFiles.indexOf(file) < 0) {
rebuildFiles.push(file);
}
}
}
const resources = await this.parseResources(
await this.parser.parseFiles(rebuildFiles, this.rootPath),
);
for (const del of removeResources) {
delete this.parsedResources[del];
}
for (const key of Object.keys(resources)) {
this.parsedResources[key] = resources[key];
}
const old = this._index || {};
this._index = await this.createIndex(this.parsedResources);
return DeclarationIndex.calculateIndexDelta(old, this._index);
}
/**
* Returns a list of files that export a certain resource (declaration).
*
* @private
* @param {string} resourceToCheck
* @returns {string[]}
*
* @memberof DeclarationIndex
*/
private getExportedResources(resourceToCheck: string): string[] {
const resources: string[] = [];
Object
.keys(this.parsedResources)
.forEach((key) => {
const resource = this.parsedResources[key];
if (resource instanceof File && this.doesExportResource(resource, resourceToCheck)) {
resources.push(resource.filePath);
}
});
return resources;
}
/**
* Checks if a file does export another resource.
* (i.e. export ... from ...)
*
* @private
* @param {File} resource The file that is checked
* @param {string} resourcePath The resource that is searched for
* @returns {boolean}
*
* @memberof DeclarationIndex
*/
private doesExportResource(resource: File, resourcePath: string): boolean {
let exportsResource = false;
for (const ex of resource.exports) {
if (exportsResource) {
break;
}
if (ex instanceof AllExport || ex instanceof NamedExport) {
const exported = '/' + toPosix(relative(this.rootPath, normalize(join(resource.parsedPath.dir, ex.from))));
exportsResource = exported === resourcePath;
}
}
return exportsResource;
}
/**
* Does parse the resources (symbols and declarations) of a given file.
* Can be cancelled with the token.
*
* @private
* @param {File[]} [files=[]]
* @returns {Promise<Resources>}
*
* @memberof DeclarationIndex
*/
private async parseResources(files: File[] = []): Promise<Resources> {
const parsedResources: Resources = Object.create(null);
for (const file of files) {
if (file.filePath.indexOf('typings') > -1 || file.filePath.indexOf('node_modules/@types') > -1) {
for (const resource of file.resources) {
parsedResources[resource.identifier] = resource;
}
} else if (file.filePath.indexOf('node_modules') > -1) {
const libname = getNodeLibraryName(file.filePath);
parsedResources[libname] = file;
} else {
parsedResources[file.identifier] = file;
}
}
for (const key of Object.keys(parsedResources).sort((k1, k2) => k2.length - k1.length)) {
const resource = parsedResources[key];
resource.declarations = resource.declarations.filter(
o => isExportableDeclaration(o) && o.isExported,
);
this.processResourceExports(parsedResources, resource);
}
return parsedResources;
}
/**
* Creates a reverse index out of the give resources.
* Can be cancelled with the token.
*
* @private
* @param {Resources} resources
* @returns {Promise<ResourceIndex>}
*
* @memberof DeclarationIndex
*/
private async createIndex(resources: Resources): Promise<{ [declaration: string]: DeclarationInfo[] }> {
// Use an empty object without a prototype, so that "toString" (for example) can be indexed
// Thanks to @gund in https://github.com/buehler/typescript-hero/issues/79
const index: { [declaration: string]: DeclarationInfo[] } = Object.create(null);
for (const key of Object.keys(resources)) {
const resource = resources[key];
if (resource instanceof Namespace || resource instanceof Module) {
if (!index[resource.name]) {
index[resource.name] = [];
}
index[resource.name].push(new DeclarationInfo(
new ModuleDeclaration(resource.getNamespaceAlias(), resource.start, resource.end),
resource.name,
));
}
for (const declaration of resource.declarations) {
if (!index[declaration.name]) {
index[declaration.name] = [];
}
const from = key.replace(/\/index$/, '') || '/';
if (!index[declaration.name].some(
o => o.declaration.constructor === declaration.constructor && o.from === from,
)) {
index[declaration.name].push(new DeclarationInfo(declaration, from));
}
}
}
return index;
}
/**
* Process all exports of a the parsed resources. Does move the declarations accordingly to their
* export nature.
*
* @private
* @param {Resources} parsedResources
* @param {Resource} resource
* @param {Resource[]} [processedResources=[]]
* @returns {void}
*
* @memberof DeclarationIndex
*/
private processResourceExports(
parsedResources: Resources,
resource: Resource,
processedResources: Resource[] = [],
): void {
if (processedResources.indexOf(resource) >= 0 || resource.exports.length === 0) {
return;
}
processedResources.push(resource);
for (const ex of resource.exports) {
if (resource instanceof File && (ex instanceof NamedExport || ex instanceof AllExport)) {
if (!ex.from) {
return;
}
let sourceLib = resolve(resource.parsedPath.dir, ex.from);
if (sourceLib.indexOf('node_modules') > -1) {
sourceLib = getNodeLibraryName(sourceLib);
} else {
sourceLib = '/' + normalizeFilename(relative(this.rootPath, sourceLib));
}
if (!parsedResources[sourceLib]) {
return;
}
const exportedLib = parsedResources[sourceLib];
this.processResourceExports(parsedResources, exportedLib, processedResources);
if (ex instanceof AllExport) {
this.processAllFromExport(resource, exportedLib);
} else {
this.processNamedFromExport(ex, resource, exportedLib);
}
} else {
if (ex instanceof AssignedExport) {
for (const lib of ex.exported.filter(o => !isExportableDeclaration(o))) {
this.processResourceExports(parsedResources, lib as Resource, processedResources);
}
this.processAssignedExport(ex, resource);
} else if (ex instanceof NamedExport && ex.from && parsedResources[ex.from]) {
this.processResourceExports(
parsedResources, parsedResources[ex.from], processedResources,
);
this.processNamedFromExport(ex, resource, parsedResources[ex.from]);
}
}
}
}
/**
* Processes an all export, does move the declarations accordingly.
* (i.e. export * from './myFile')
*
* @private
* @param {Resource} exportingLib
* @param {Resource} exportedLib
*
* @memberof DeclarationIndex
*/
private processAllFromExport(exportingLib: Resource, exportedLib: Resource): void {
exportingLib.declarations.push(...exportedLib.declarations);
exportedLib.declarations = [];
}
/**
* Processes a named export, does move the declarations accordingly.
* (i.e. export {MyClass} from './myFile')
*
* @private
* @param {NamedExport} tsExport
* @param {Resource} exportingLib
* @param {Resource} exportedLib
*
* @memberof DeclarationIndex
*/
private processNamedFromExport(
tsExport: NamedExport,
exportingLib: Resource,
exportedLib: Resource,
): void {
exportedLib.declarations
.forEach((o) => {
if (!tsExport.specifiers) {
return;
}
const ex = tsExport.specifiers.find(s => s.specifier === o.name);
if (!ex) {
return;
}
exportedLib.declarations.splice(exportedLib.declarations.indexOf(o), 1);
if (ex.alias) {
o.name = ex.alias;
}
exportingLib.declarations.push(o);
});
}
/**
* Processes an assigned export, does move the declarations accordingly.
* (i.e. export = namespaceName)
*
* @private
* @param {AssignedExport} tsExport
* @param {Resource} exportingLib
*
* @memberof DeclarationIndex
*/
private processAssignedExport(
tsExport: AssignedExport,
exportingLib: Resource,
): void {
tsExport.exported.forEach((exported) => {
if (isExportableDeclaration(exported)) {
exportingLib.declarations.push(exported);
} else {
exportingLib.declarations.push(
...exported.declarations.filter(
o => isExportableDeclaration(o) && o.isExported,
),
);
exported.declarations = [];
}
});
}
}
================================================
FILE: src/Node.ts
================================================
/**
* Base class for all nodes / declarations / imports / etc. in the extension.
* Contains basic information about the node.
*
* @export
* @interface Node
*/
export interface Node {
/**
* The starting character of the node in the document.
*
* @type {number}
* @memberof Node
*/
start?: number;
/**
* The ending character of the node in the document.
*
* @type {number}
* @memberof Node
*/
end?: number;
}
================================================
FILE: src/SymbolSpecifier.ts
================================================
import { Clonable } from './clonable/Clonable';
/**
* Class for symbols that are contained in a named import or export or anywhere. Basically an aliased object.
* (i.e. import {SYMBOL} from '...').
*
* @export
* @class SymbolSpecifier
* @implements {Clonable}
*/
export class SymbolSpecifier implements Clonable<SymbolSpecifier> {
constructor(public specifier: string, public alias?: string) { }
/**
* Clones the current resolve specifier and returns a new instance with the same properties.
*
* @returns {SymbolSpecifier}
*
* @memberof SymbolSpecifier
*/
public clone(): SymbolSpecifier {
return new SymbolSpecifier(this.specifier, this.alias);
}
}
================================================
FILE: src/TypescriptParser.ts
================================================
import { readFileSync } from 'fs';
import { parse } from 'path';
import {
ClassDeclaration,
createSourceFile,
EnumDeclaration,
ExportAssignment,
ExportDeclaration,
FunctionDeclaration,
Identifier,
ImportDeclaration,
ImportEqualsDeclaration,
InterfaceDeclaration,
ModuleDeclaration,
Node,
ScriptKind,
ScriptTarget,
SourceFile,
SyntaxKind,
TypeAliasDeclaration,
VariableStatement,
} from 'typescript';
import { parseClass } from './node-parser/class-parser';
import { parseEnum } from './node-parser/enum-parser';
import { parseExport } from './node-parser/export-parser';
import { parseFunction } from './node-parser/function-parser';
import { parseIdentifier } from './node-parser/identifier-parser';
import { parseImport } from './node-parser/import-parser';
import { parseInterface } from './node-parser/interface-parser';
import { parseModule } from './node-parser/module-parser';
import { traverseAst } from './node-parser/traverse-ast';
import { parseTypeAlias } from './node-parser/type-alias-parser';
import { parseVariable } from './node-parser/variable-parser';
import { File } from './resources/File';
import { Resource } from './resources/Resource';
/**
* Magic.happens('here');
* This class is the parser of the whole extension. It uses the typescript compiler to parse a file or given
* source code into the token stream and therefore into the AST of the source. Afterwards an array of
* resources is generated and returned.
*
* @export
* @class TypescriptParser
*/
export class TypescriptParser {
/**
* Parses the given source into an anonymous File resource.
* Mainly used to parse source code of a document.
*
* @param {string} source
* @param {ScriptKind} [scriptKind=ScriptKind.TS]
* @returns {Promise<File>}
*
* @memberof TsResourceParser
*/
public async parseSource(source: string, scriptKind: ScriptKind = ScriptKind.TS): Promise<File> {
return await this.parseTypescript(
createSourceFile(
'inline.tsx',
source,
ScriptTarget.ES2015,
true,
scriptKind),
'/');
}
/**
* Parses a single file into a parsed file.
*
* @param {string} filePath
* @param {string} rootPath
* @returns {Promise<File>}
*
* @memberof TsResourceParser
*/
public async parseFile(filePath: string, rootPath: string): Promise<File> {
const parse = await this.parseFiles([filePath], rootPath);
return parse[0];
}
/**
* Parses multiple files into parsed files.
*
* @param {string[]} filePathes
* @param {string} rootPath
* @returns {Promise<File[]>}
*
* @memberof TsResourceParser
*/
public async parseFiles(
filePathes: string[],
rootPath: string): Promise<File[]> {
return filePathes
.map((o) => {
let scriptKind: ScriptKind = ScriptKind.Unknown;
const parsed = parse(o);
switch (parsed.ext.toLowerCase()) {
case 'js':
scriptKind = ScriptKind.JS;
break;
case 'jsx':
scriptKind = ScriptKind.JSX;
break;
case 'ts':
scriptKind = ScriptKind.TS;
break;
case 'tsx':
scriptKind = ScriptKind.TSX;
break;
}
return createSourceFile(
o,
readFileSync(o).toString(),
ScriptTarget.ES2015,
true,
scriptKind,
);
})
.map(o => this.parseTypescript(o, rootPath));
}
/**
* Parses the typescript source into the file instance. Calls .parse afterwards to
* get the declarations and other information about the source.
*
* @private
* @param {SourceFile} source
* @param {string} rootPath
* @returns {TsFile}
*
* @memberof TsResourceParser
*/
private parseTypescript(source: SourceFile, rootPath: string): File {
const file = new File(source.fileName, rootPath, source.getStart(), source.getEnd());
const syntaxList = source.getChildAt(0);
this.parse(file, syntaxList);
return file;
}
/**
* Recursive function that runs through the AST of a source and parses the nodes.
* Creates the class / function / etc declarations and instanciates a new module / namespace
* resource if needed.
*
* @private
* @param {Resource} resource
* @param {Node} node
*
* @memberof TsResourceParser
*/
private parse(resource: Resource, root: Node): void {
const modules = [{ moduleRoot: root, moduleResource: resource }];
for (let iter = modules.shift(); iter !== undefined; iter = modules.shift()) {
const { moduleRoot, moduleResource } = iter;
traverseAst(
moduleRoot as any,
(node: any) => {
switch (node.kind) {
case SyntaxKind.ImportDeclaration:
case SyntaxKind.ImportEqualsDeclaration:
parseImport(moduleResource, <ImportDeclaration | ImportEqualsDeclaration>node);
break;
case SyntaxKind.ExportDeclaration:
case SyntaxKind.ExportAssignment:
parseExport(moduleResource, <ExportAssignment | ExportDeclaration>node);
break;
case SyntaxKind.EnumDeclaration:
parseEnum(moduleResource, <EnumDeclaration>node);
break;
case SyntaxKind.TypeAliasDeclaration:
parseTypeAlias(moduleResource, <TypeAliasDeclaration>node);
break;
case SyntaxKind.FunctionDeclaration:
parseFunction(moduleResource, <FunctionDeclaration>node);
break;
case SyntaxKind.VariableStatement:
parseVariable(moduleResource, <VariableStatement>node);
break;
case SyntaxKind.InterfaceDeclaration:
parseInterface(moduleResource, <InterfaceDeclaration>node);
break;
case SyntaxKind.ClassDeclaration:
parseClass(moduleResource, <ClassDeclaration>node);
break;
case SyntaxKind.Identifier:
parseIdentifier(moduleResource, <Identifier>node);
break;
case SyntaxKind.ModuleDeclaration:
modules.push({
moduleRoot: node,
moduleResource: parseModule(moduleResource, <ModuleDeclaration>node),
});
break;
default:
break;
}
},
(node: any) => {
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
case SyntaxKind.ModuleDeclaration:
case SyntaxKind.FunctionDeclaration:
return true;
default:
return false;
}
},
);
}
}
}
================================================
FILE: src/clonable/Clonable.ts
================================================
/**
* Interface for clonable objects. The clone() method creates a deep clone of the object.
*
* @export
* @template T
* @interface Clonable
*/
export interface Clonable<T> {
/**
* Create a deep clone of this object.
*
* @returns {T}
*
* @memberof Clonable
*/
clone(): T;
}
================================================
FILE: src/code-generators/TypescriptCodeGenerator.ts
================================================
import { GetterDeclaration, SetterDeclaration } from '../declarations/AccessorDeclaration';
import { Declaration } from '../declarations/Declaration';
import { MethodDeclaration } from '../declarations/MethodDeclaration';
import { ParameterDeclaration } from '../declarations/ParameterDeclaration';
import { PropertyDeclaration } from '../declarations/PropertyDeclaration';
import { VariableDeclaration } from '../declarations/VariableDeclaration';
import { NotGeneratableYetError } from '../errors/NotGeneratableYetError';
import { Export } from '../exports/Export';
import { ExternalModuleImport } from '../imports/ExternalModuleImport';
import { Import } from '../imports/Import';
import { NamedImport } from '../imports/NamedImport';
import { NamespaceImport } from '../imports/NamespaceImport';
import { StringImport } from '../imports/StringImport';
import { SymbolSpecifier } from '../SymbolSpecifier';
import { generateAccessorDeclaration } from './typescript-generators/accessorDeclaration';
import { generateExternalModuleImport } from './typescript-generators/externalModuleImport';
import { generateMethodDeclaration } from './typescript-generators/methodDeclaration';
import { generateNamedImport } from './typescript-generators/namedImport';
import { generateNamespaceImport } from './typescript-generators/namespaceImport';
import { generateParameterDeclaration } from './typescript-generators/parameterDeclaration';
import { generatePropertyDeclaration } from './typescript-generators/propertyDeclaration';
import { generateStringImport } from './typescript-generators/stringImport';
import { generateSymbolSpecifier } from './typescript-generators/symbolSpecifier';
import { generateVariableDelcaration } from './typescript-generators/variableDeclaration';
import { TypescriptGenerationOptions } from './TypescriptGenerationOptions';
/**
* All generatable items combined. If the element is not generatable, the specific generator should throw
* an exception.
*/
export type Generatable = Declaration | Import | Export | SymbolSpecifier;
/**
* Type for generators.
*/
export type Generators = { [name: string]: (generatable: Generatable, options: TypescriptGenerationOptions) => string };
/**
* Hash with all possible (yet implemented) generators.
*/
export const GENERATORS: Generators = {
[SymbolSpecifier.name]: generateSymbolSpecifier as any,
[MethodDeclaration.name]: generateMethodDeclaration,
[ParameterDeclaration.name]: generateParameterDeclaration,
[PropertyDeclaration.name]: generatePropertyDeclaration,
[VariableDeclaration.name]: generateVariableDelcaration,
[ExternalModuleImport.name]: generateExternalModuleImport,
[NamedImport.name]: generateNamedImport,
[NamespaceImport.name]: generateNamespaceImport,
[StringImport.name]: generateStringImport,
[SetterDeclaration.name]: generateAccessorDeclaration,
[GetterDeclaration.name]: generateAccessorDeclaration,
};
/**
* Generator for typescript code elements. Takes a generatable object and tries to generate typescript code.
*
* @export
* @class TypescriptCodeGenerator
*/
export class TypescriptCodeGenerator {
constructor(private options: TypescriptGenerationOptions) { }
/**
* Generator function. Calls the specific element generator. If no generator is found, an exception is thrown.
*
* @param {Generatable} declaration
* @returns {string}
* @throws {NotGeneratableYetError}
* @memberof TypescriptCodeGenerator
*/
public generate(declaration: Generatable): string {
if (GENERATORS[declaration.constructor.name]) {
return GENERATORS[declaration.constructor.name](declaration, this.options);
}
throw new NotGeneratableYetError(declaration);
}
}
================================================
FILE: src/code-generators/TypescriptGenerationOptions.ts
================================================
export enum MultiLineImportRule {
strictlyOneImportPerLine = 'strictlyOneImportPerLine',
oneImportPerLineOnlyAfterThreshold = 'oneImportPerLineOnlyAfterThreshold',
multipleImportsPerLine = 'multipleImportsPerLine',
}
/**
* Typescript generation options type. Contains all information needed to stringify some objects to typescript.
*
* @export
* @interface TypescriptGenerationOptions
*/
export interface TypescriptGenerationOptions {
/**
* Which quote type should be used (' or ").
*
* @type {string}
* @memberof TypescriptGenerationOptions
*/
stringQuoteStyle: string;
/**
* Defines end of line character (semicolon or nothing).
*
* @type {('' | ';')}
* @memberof TypescriptGenerationOptions
*/
eol: '' | ';';
/**
* Defines if the symbols should have spacing in the braces ({ Foo } or {Foo}).
*
* @type {boolean}
* @memberof TypescriptGenerationOptions
*/
spaceBraces: boolean;
/**
* The wrapping methodology to be used for imports.
*
* @type {MultiLineImportRule}
* @memberof TypescriptGenerationOptions
*/
wrapMethod: MultiLineImportRule;
/**
* The threshold where an import is written as multiline.
*
* @type {number}
* @memberof TypescriptGenerationOptions
*/
multiLineWrapThreshold: number;
/**
* Defines if the last line of a multiline import should have a comma.
*
* @type {boolean}
* @memberof TypescriptGenerationOptions
*/
multiLineTrailingComma: boolean;
/**
* How many spaces of indentiation.
*
* @type {number}
* @memberof TypescriptGenerationOptions
*/
tabSize: number;
/**
* Insert spaces instead of tabs (default: true)
*
* @type {boolean}
* @memberof TypescriptGenerationOptions
*/
insertSpaces: boolean;
}
================================================
FILE: src/code-generators/typescript-generators/accessorDeclaration.ts
================================================
import { AccessorDeclaration, SetterDeclaration } from '../../declarations/AccessorDeclaration';
import { getVisibilityText } from '../../declarations/DeclarationVisibility';
import { TypescriptGenerationOptions } from '../TypescriptGenerationOptions';
/**
* Generates typescript code for a class property accessor.
*
* @export
* @param {AccessorDeclaration} accessor
* @param {TypescriptGenerationOptions} { tabSize }
* @returns {string}
*/
export function generateAccessorDeclaration(
accessor: AccessorDeclaration,
{ tabSize }: TypescriptGenerationOptions,
): string {
const tabs = Array(tabSize + 1).join(' ');
let definitionLine: string;
if (accessor instanceof SetterDeclaration) {
definitionLine = `${tabs}${accessor.visibility !== undefined ? getVisibilityText(accessor.visibility) + ' ' : ''}` +
`${accessor.isAbstract ? 'abstract ' : ''}` +
`set ${accessor.name}(value${accessor.type ? `: ${accessor.type}` : ''})`;
} else {
definitionLine = `${tabs}${accessor.visibility !== undefined ? getVisibilityText(accessor.visibility) + ' ' : ''}` +
`${accessor.isAbstract ? 'abstract ' : ''}` +
`get ${accessor.name}()${accessor.type ? `: ${accessor.type}` : ''}`;
}
if (accessor.isAbstract) {
return `${definitionLine};`;
}
return `${definitionLine} {
${tabs}${tabs}throw new Error('Not implemented yet.');
${tabs}}\n`;
}
================================================
FILE: src/code-generators/typescript-generators/externalModuleImport.ts
================================================
import { ExternalModuleImport } from '../../imports/ExternalModuleImport';
import { TypescriptGenerationOptions } from '../TypescriptGenerationOptions';
/**
* Generates typescript code for an external module import.
*
* @export
* @param {ExternalModuleImport} imp
* @param {TypescriptGenerationOptions} { stringQuoteStyle, eol }
* @returns {string}
*/
export function generateExternalModuleImport(
imp: ExternalModuleImport,
{ stringQuoteStyle, eol }: TypescriptGenerationOptions,
): string {
return `import ${imp.alias} = require(${stringQuoteStyle}${imp.libraryName}${stringQuoteStyle})${eol}`;
}
================================================
FILE: src/code-generators/typescript-generators/methodDeclaration.ts
================================================
import { getVisibilityText } from '../../declarations/DeclarationVisibility';
import { MethodDeclaration } from '../../declarations/MethodDeclaration';
import { TypescriptGenerationOptions } from '../TypescriptGenerationOptions';
import { generateParameterDeclaration } from './parameterDeclaration';
/**
* Generates typescript code for a method declaration.
*
* @export
* @param {MethodDeclaration} method
* @param {TypescriptGenerationOptions} { tabSize }
* @returns {string}
*/
export function generateMethodDeclaration(method: MethodDeclaration, { tabSize }: TypescriptGenerationOptions): string {
const intend = Array(tabSize + 1).join(' ');
return `${intend}` +
`${method.visibility !== undefined ? getVisibilityText(method.visibility) + ' ' : ''}${method.name}(` +
`${method.parameters.map(o => generateParameterDeclaration(o)).join(', ')})` +
`${method.type ? `: ${method.type}` : ''} {
${intend}${intend}throw new Error('Not implemented yet.');
${intend}}\n`;
}
================================================
FILE: src/code-generators/typescript-generators/namedImport.ts
================================================
import { NamedImport } from '../../imports/NamedImport';
import { SymbolSpecifier } from '../../SymbolSpecifier';
import { stringTemplate } from '../../utilities/StringTemplate';
import { MultiLineImportRule, TypescriptGenerationOptions } from '../TypescriptGenerationOptions';
import { generateSymbolSpecifier } from './symbolSpecifier';
const oneLinerImportTemplate = stringTemplate`import ${0} from ${1}`;
const multiLineImportTemplate = stringTemplate`import ${3}{
${0}${1}
} from ${2}`;
const defaultAliasOnlyMultiLineImportTemplate = stringTemplate`import ${0}
from ${1}`;
/**
* Sort function for symbol specifiers. Does sort after the specifiers name (to lowercase).
*
* @param {SymbolSpecifier} i1
* @param {SymbolSpecifier} i2
* @returns {number}
*/
function specifierSort(i1: SymbolSpecifier, i2: SymbolSpecifier): number {
const strA = i1.specifier.toLowerCase();
const strB = i2.specifier.toLowerCase();
if (strA < strB) {
return -1;
}
if (strA > strB) {
return 1;
}
return 0;
}
/**
* Generates typescript code for a named import.
*
* @export
* @param {NamedImport} imp
* @param {TypescriptGenerationOptions} { stringQuoteStyle, eol }
* @returns {string}
*/
export function generateNamedImport(
imp: NamedImport,
{
eol,
stringQuoteStyle,
spaceBraces,
tabSize,
wrapMethod,
multiLineWrapThreshold,
multiLineTrailingComma,
insertSpaces = true,
}: TypescriptGenerationOptions,
): string {
const lib = `${stringQuoteStyle}${imp.libraryName}${stringQuoteStyle}${eol}`;
// const specifiers = imp.specifiers.sort(specifierSort).map(o => generateSymbolSpecifier(o)).join(', ');
const oneLinerImportStatement = oneLinerImportTemplate(getImportSpecifiers(imp, spaceBraces), lib);
if (oneLinerImportStatement.length <= multiLineWrapThreshold &&
(wrapMethod !== MultiLineImportRule.strictlyOneImportPerLine ||
imp.specifiers.length <= 1)) {
return oneLinerImportStatement;
}
const defaultAliasOnly: boolean = imp.specifiers.length === 0;
if (defaultAliasOnly) {
return defaultAliasOnlyMultiLineImportTemplate(
imp.defaultAlias ? `${imp.defaultAlias}, ` : '',
`${stringQuoteStyle}${imp.libraryName}${stringQuoteStyle}${eol}`,
);
}
const sortedImportSpecifiers: SymbolSpecifier[] = imp.specifiers.sort(specifierSort);
let importSpecifierStrings: string = '';
const indent = insertSpaces ? Array(tabSize + 1).join(' ') : '\t';
if (wrapMethod === MultiLineImportRule.strictlyOneImportPerLine ||
wrapMethod === MultiLineImportRule.oneImportPerLineOnlyAfterThreshold) {
importSpecifierStrings = sortedImportSpecifiers.map(o => `${indent}${generateSymbolSpecifier(o)}`).join(',\n');
} else if (wrapMethod === MultiLineImportRule.multipleImportsPerLine) {
importSpecifierStrings = sortedImportSpecifiers.reduce(
(acc, curr) => {
const symbolSpecifier: string = generateSymbolSpecifier(curr);
// const dist: number = acc.out.length - acc.lastWrapOffset + symbolSpecifier.length;
const importLines = acc.out.split('\n');
const lastImportLine = importLines[importLines.length - 1];
const dist: number = lastImportLine.length + `, `.length + symbolSpecifier.length;
const needsWrap: boolean = dist >= multiLineWrapThreshold;
return {
out: acc.out + (needsWrap ? `,\n${indent}` : (acc.out.length ? `, ` : `${indent}`)) +
symbolSpecifier,
lastWrapOffset: acc.lastWrapOffset + (needsWrap ? dist : 0),
};
},
{
out: '',
lastWrapOffset: 0,
},
).out;
}
return multiLineImportTemplate(
importSpecifierStrings,
multiLineTrailingComma ? ',' : '',
`${stringQuoteStyle}${imp.libraryName}${stringQuoteStyle}${eol}`,
imp.defaultAlias ? `${imp.defaultAlias}, ` : '',
);
}
function getImportSpecifiers(namedImport: NamedImport, spaceBraces: boolean): string {
if (namedImport.defaultAlias && namedImport.specifiers.length <= 0) {
return namedImport.defaultAlias;
}
const space = spaceBraces ? ' ' : '';
const specifiers = namedImport.specifiers.sort(specifierSort).map(o => generateSymbolSpecifier(o)).join(', ');
let importSpecifiers = `${space}${specifiers}${space}`;
if (importSpecifiers.trim().length === 0) {
importSpecifiers = ' ';
}
if (namedImport.defaultAlias && namedImport.specifiers.length > 0) {
return `${namedImport.defaultAlias}, {${importSpecifiers}}`;
}
return `{${importSpecifiers}}`;
}
================================================
FILE: src/code-generators/typescript-generators/namespaceImport.ts
================================================
import { NamespaceImport } from '../../imports/NamespaceImport';
import { TypescriptGenerationOptions } from '../TypescriptGenerationOptions';
/**
* Generates typescript code for a namespace import
*
* @export
* @param {NamespaceImport} imp
* @param {TypescriptGenerationOptions} { stringQuoteStyle, eol }
* @returns {string}
*/
export function generateNamespaceImport(
imp: NamespaceImport,
{ stringQuoteStyle, eol }: TypescriptGenerationOptions,
): string {
return `import * as ${imp.alias} from ${stringQuoteStyle}${imp.libraryName}${stringQuoteStyle}${eol}`;
}
================================================
FILE: src/code-generators/typescript-generators/parameterDeclaration.ts
================================================
import { ParameterDeclaration } from '../../declarations/ParameterDeclaration';
/**
* Generates typescript code for parameters.
*
* @export
* @param {ParameterDeclaration} parameter
* @returns {string}
*/
export function generateParameterDeclaration(parameter: ParameterDeclaration): string {
return `${parameter.name}${parameter.type ? `: ${parameter.type}` : ''}`;
}
================================================
FILE: src/code-generators/typescript-generators/propertyDeclaration.ts
================================================
import { getVisibilityText } from '../../declarations/DeclarationVisibility';
import { PropertyDeclaration } from '../../declarations/PropertyDeclaration';
import { TypescriptGenerationOptions } from '../TypescriptGenerationOptions';
/**
* Generates typescript code for a class property.
*
* @export
* @param {PropertyDeclaration} property
* @param {TypescriptGenerationOptions} { tabSize }
* @returns {string}
*/
export function generatePropertyDeclaration(
property: PropertyDeclaration,
{ tabSize }: TypescriptGenerationOptions,
): string {
return `${Array(tabSize + 1).join(' ')}` +
`${property.visibility !== undefined ? getVisibilityText(property.visibility) + ' ' : ''}` +
`${property.name}${property.isOptional ? '?' : ''}${property.type ? `: ${property.type}` : ''};\n`;
}
================================================
FILE: src/code-generators/typescript-generators/stringImport.ts
================================================
import { StringImport } from '../../imports/StringImport';
import { TypescriptGenerationOptions } from '../TypescriptGenerationOptions';
/**
* Generates typescript code for a string import.
*
* @export
* @param {StringImport} imp
* @param {TypescriptGenerationOptions} { stringQuoteStyle, eol }
* @returns {string}
*/
export function generateStringImport(imp: StringImport, { stringQuoteStyle, eol }: TypescriptGenerationOptions): string {
return `import ${stringQuoteStyle}${imp.libraryName}${stringQuoteStyle}${eol}`;
}
================================================
FILE: src/code-generators/typescript-generators/symbolSpecifier.ts
================================================
import { SymbolSpecifier } from '../../SymbolSpecifier';
/**
* Generates typescript code for a symbol specifier.
*
* @export
* @param {SymbolSpecifier} specifier
* @returns {string}
*/
export function generateSymbolSpecifier(specifier: SymbolSpecifier): string {
return `${specifier.specifier}${specifier.alias ? ` as ${specifier.alias}` : ''}`;
}
================================================
FILE: src/code-generators/typescript-generators/variableDeclaration.ts
================================================
import { VariableDeclaration } from '../../declarations/VariableDeclaration';
/**
* Generates typescript code for a variable.
*
* @export
* @param {VariableDelcaration} variable
* @returns {string}
*/
export function generateVariableDelcaration(variable: VariableDeclaration): string {
return `${variable.name}${variable.type ? `: ${variable.type}` : ''}`;
}
================================================
FILE: src/declarations/AccessorDeclaration.ts
================================================
import { AbstractDeclaration, ScopedDeclaration, StaticDeclaration, TypedDeclaration } from './Declaration';
import { DeclarationVisibility } from './DeclarationVisibility';
/**
* Property accessor declaration. This element represents the base and will be used in setters and getters.
*
* @export
* @abstract
* @class AccessorDeclaration
* @implements {ScopedDeclaration}
* @implements {TypedDeclaration}
* @implements {AbstractDeclaration}
*/
export abstract class AccessorDeclaration implements
ScopedDeclaration,
StaticDeclaration,
TypedDeclaration,
AbstractDeclaration {
constructor(
public name: string,
public visibility: DeclarationVisibility | undefined,
public type: string | undefined,
public isAbstract: boolean,
public isStatic: boolean,
public start?: number,
public end?: number,
) { }
}
/**
* Getter declaration for a getter accessor of a class property.
*
* @export
* @class GetterDeclaration
* @extends {AccessorDeclaration}
*/
export class GetterDeclaration extends AccessorDeclaration { }
/**
* Setter declaration for a getter accessor of a class property.
*
* @export
* @class SetterDeclaration
* @extends {AccessorDeclaration}
*/
export class SetterDeclaration extends AccessorDeclaration { }
================================================
FILE: src/declarations/ClassDeclaration.ts
================================================
import { AccessorDeclaration } from './AccessorDeclaration';
import { ConstructorDeclaration } from './ConstructorDeclaration';
import { ClassLikeDeclaration, ExportableDeclaration, GenericDeclaration } from './Declaration';
import { MethodDeclaration } from './MethodDeclaration';
import { PropertyDeclaration } from './PropertyDeclaration';
/**
* Class declaration that contains methods, properties and a constructor
*
* @export
* @class ClassDeclaration
* @implements {ClassLikeDeclaration}
* @implements {ExportableDeclaration}
* @implements {GenericDeclaration}
*/
export class ClassDeclaration implements ClassLikeDeclaration, ExportableDeclaration, GenericDeclaration {
public ctor: ConstructorDeclaration | undefined;
public accessors: AccessorDeclaration[] = [];
public properties: PropertyDeclaration[] = [];
public methods: MethodDeclaration[] = [];
public typeParameters: string[] | undefined;
constructor(
public name: string,
public isExported: boolean,
public start?: number,
public end?: number,
) { }
}
================================================
FILE: src/declarations/ConstructorDeclaration.ts
================================================
import { CallableDeclaration } from './Declaration';
import { ParameterDeclaration } from './ParameterDeclaration';
import { VariableDeclaration } from './VariableDeclaration';
/**
* Constructor declaration that is contained in a class.
*
* @export
* @class ConstructorDeclaration
* @implements {CallableDeclaration}
*/
export class ConstructorDeclaration implements CallableDeclaration {
public parameters: ParameterDeclaration[] = [];
public variables: VariableDeclaration[] = [];
constructor(
public name: string,
public start?: number,
public end?: number,
) { }
}
================================================
FILE: src/declarations/Declaration.ts
================================================
import { Node } from '../Node';
import { AccessorDeclaration } from './AccessorDeclaration';
import { DeclarationVisibility } from './DeclarationVisibility';
import { MethodDeclaration } from './MethodDeclaration';
import { ParameterDeclaration } from './ParameterDeclaration';
import { PropertyDeclaration } from './PropertyDeclaration';
import { VariableDeclaration } from './VariableDeclaration';
/**
* Basic interface for all declarations. Defines the basic needed information for a typescript declaration.
*
* @export
* @interface Declaration
* @extends {Node}
*/
export interface Declaration extends Node {
/**
* The name of the declaration.
*
* @type {string}
* @memberof Declaration
*/
name: string;
}
/**
* Interface for all typed declarations. Those declarations contain a type that must be taken care of.
* (e.g. 'string' or 'number')
*
* @export
* @interface TypedDeclaration
* @extends {Declaration}
*/
export interface TypedDeclaration extends Declaration {
/**
* The type of the declaration.
*
* @type {(string | undefined)}
* @example "string"
* @example "Declaration[]"
* @memberof TypedDeclaration
*/
type: string | undefined;
}
/**
* Interface for generic type declarations. Those declarations are able to be used in a generic way.
* Examples are: classes, interfaces, methods and such.
*
* @export
* @interface GenericDeclaration
* @extends {Declaration}
*/
export interface GenericDeclaration extends Declaration {
/**
* List of type parameters
*
* @type {(string[] | undefined)}
* @memberof GenericDeclaration
*
* @example
* ['T', 'TResult', 'TError']
*/
typeParameters: string[] | undefined;
}
/**
* Interface for exportable declarations. Does contain information about the export status of a declaration.
*
* @export
* @interface ExportableDeclaration
* @extends {Declaration}
*/
export interface ExportableDeclaration extends Declaration {
/**
* Indicates if the declaration is exported (i.e. export function ...) or not.
*
* @type {boolean}
* @memberof ExportableDeclaration
*/
isExported: boolean;
}
/**
* Interface for visible declarations. Does contain information about the visibility of the declaration.
*
* @export
* @interface ScopedDeclaration
* @extends {Declaration}
*/
export interface ScopedDeclaration extends Declaration {
/**
* Defines the visibility scope of the declaration. Can be undefined, in which case there
* is no visibility given (e.g. methods in interfaces).
*
* @type {(DeclarationVisibility | undefined)}
* @memberof ScopedDeclaration
*/
visibility: DeclarationVisibility | undefined;
}
/**
* Interface for class like constructs. Contain properties and methods that are contained.
* Examples are classes, interfaces, abstract classes, etc.
*
* @export
* @interface ClassLikeDeclaration
* @extends {Declaration}
*/
export interface ClassLikeDeclaration extends Declaration {
/**
* Accessors of this class.
*
* @type {AccessorDeclaration[]}
* @memberof ClassLikeDeclaration
*/
accessors: AccessorDeclaration[];
/**
* The properties of the declaration.
*
* @type {PropertyDeclaration[]}
* @memberof ClassLikeDeclaration
*/
properties: PropertyDeclaration[];
/**
* The methods of the declaration.
*
* @type {MethodDeclaration[]}
* @memberof ClassLikeDeclaration
*/
methods: MethodDeclaration[];
}
/**
* Interface for callable declarations. Contains lists for parameters and used variables in the callable
* definitions.
*
* @export
* @interface CallableDeclaration
* @extends {Declaration}
*/
export interface CallableDeclaration extends Declaration {
/**
* List of used parameters in the callable node.
*
* @type {ParameterDeclaration[]}
* @memberof CallableDeclaration
*/
parameters: ParameterDeclaration[];
/**
* List of used variables in the callable node.
*
* @type {VariableDeclaration[]}
* @memberof CallableDeclaration
*/
variables: VariableDeclaration[];
}
/**
* Interface for possible abstract declarations. Contains information if the element is abstract or not.
*
* @export
* @interface AbstractDeclaration
* @extends {Declaration}
*/
export interface AbstractDeclaration extends Declaration {
/**
* Defines if the declaration is abstract or not.
*
* @type {boolean}
* @memberof AbstractDeclaration
*/
isAbstract: boolean;
}
/**
* Interface for possible optional declarations. Contains information if the element is optional or not.
*
* @export
* @interface OptionalDeclaration
* @extends {Declaration}
*/
export interface OptionalDeclaration extends Declaration {
/**
* Defines if the declaration is optional or not.
*
* @type {boolean}
* @memberof OptionalDeclaration
*/
isOptional: boolean;
}
/**
* Interface for possible static declarations.
*
* @export
* @interface StaticDeclaration
* @extends {Declaration}
*/
export interface StaticDeclaration extends Declaration {
/**
* Defines if the declaration is static or not.
*
* @type {boolean}
* @memberof StaticDeclaration
*/
isStatic: boolean;
}
/**
* Interface for possible async declarations.
*
* @export
* @interface AsyncDeclaration
* @extends {Declaration}
*/
export interface AsyncDeclaration extends Declaration {
/**
* Defines if the declaration is async or not.
*
* @type {boolean}
* @memberof AsyncDeclaration
*/
isAsync: boolean;
}
================================================
FILE: src/declarations/DeclarationInfo.ts
================================================
import { Declaration } from './Declaration';
/**
* Class that defines information about a declaration.
* Contains the declaration and the origin of the declaration.
*
* @export
* @class DeclarationInfo
*/
export class DeclarationInfo {
constructor(public declaration: Declaration, public from: string) { }
}
================================================
FILE: src/declarations/DeclarationVisibility.ts
================================================
/**
* Returns the visibility string for a given enum value.
*
* @param {DeclarationVisibility} [visibility]
* @returns {string}
*/
export function getVisibilityText(visibility?: DeclarationVisibility): string {
switch (visibility) {
case DeclarationVisibility.Private:
return 'private';
case DeclarationVisibility.Public:
return 'public';
case DeclarationVisibility.Protected:
return 'protected';
default:
return '';
}
}
/**
* Visibility of a class or interface property, as well as a method.
*
* @export
* @enum {number}
*/
export const enum DeclarationVisibility {
Private,
Protected,
Public,
}
================================================
FILE: src/declarations/DefaultDeclaration.ts
================================================
import { Resource } from '../resources/Resource';
import { Declaration, ExportableDeclaration } from './Declaration';
/**
* Default declaration. Is used when a file exports something as its default.
* Primary use is to ask the user about a name for the default export.
* Is kind of an abstract declaration since there is no real declaration.
*
* @export
* @class DefaultDeclaration
* @implements {ExportableDeclaration}
*/
export class DefaultDeclaration implements ExportableDeclaration {
public readonly isExported: boolean = true;
private exported: Declaration | undefined;
public get exportedDeclaration(): Declaration {
if (!this.exported) {
this.exported = this.resource.declarations.find(o => o.name === this.name)!;
}
return this.exported;
}
constructor(
public name: string,
private resource: Resource,
public start?: number,
public end?: number,
) { }
}
================================================
FILE: src/declarations/EnumDeclaration.ts
================================================
import { ExportableDeclaration } from './Declaration';
/**
* Enum declaration.
*
* @export
* @class EnumDeclaration
* @implements {ExportableDeclaration}
*/
export class EnumDeclaration implements ExportableDeclaration {
public members: string[] = [];
constructor(
public name: string,
public isExported: boolean,
public start?: number,
public end?: number,
) { }
}
================================================
FILE: src/declarations/FunctionDeclaration.ts
================================================
import { AsyncDeclaration, CallableDeclaration, ExportableDeclaration } from './Declaration';
import { ParameterDeclaration } from './ParameterDeclaration';
import { VariableDeclaration } from './VariableDeclaration';
/**
* Function declaration. Like the MethodDeclaration it contains the base info about the function
* and additional stuff.
*
* @export
* @class FunctionDeclaration
* @implements {CallableDeclaration}
* @implements {ExportableDeclaration}
*/
export class FunctionDeclaration implements AsyncDeclaration, CallableDeclaration, ExportableDeclaration {
public parameters: ParameterDeclaration[] = [];
public variables: VariableDeclaration[] = [];
constructor(
public name: string,
public isExported: boolean,
public isAsync: boolean,
public type?: string,
public start?: number,
public end?: number,
) { }
}
================================================
FILE: src/declarations/InterfaceDeclaration.ts
================================================
import { AccessorDeclaration } from './AccessorDeclaration';
import { ClassLikeDeclaration, ExportableDeclaration, GenericDeclaration } from './Declaration';
import { MethodDeclaration } from './MethodDeclaration';
import { PropertyDeclaration } from './PropertyDeclaration';
/**
* Interface declaration that contains defined properties and methods.
*
* @export
* @class InterfaceDeclaration
* @implements {ExportableDeclaration}
* @implements {GenericDeclaration}
*/
export class InterfaceDeclaration implements ClassLikeDeclaration, ExportableDeclaration, GenericDeclaration {
public accessors: AccessorDeclaration[] = [];
public typeParameters: string[] | undefined;
public properties: PropertyDeclaration[] = [];
public methods: MethodDeclaration[] = [];
constructor(
public name: string,
public isExported: boolean,
public start?: number,
public end?: number,
) { }
}
================================================
FILE: src/declarations/MethodDeclaration.ts
================================================
import {
AbstractDeclaration,
AsyncDeclaration,
CallableDeclaration,
OptionalDeclaration,
ScopedDeclaration,
StaticDeclaration,
TypedDeclaration,
} from './Declaration';
import { DeclarationVisibility } from './DeclarationVisibility';
import { ParameterDeclaration } from './ParameterDeclaration';
import { VariableDeclaration } from './VariableDeclaration';
/**
* Method declaration. A method is contained in an interface or a class.
* Contains information abount the method itself.
*
* @export
* @class MethodDeclaration
* @implements {CallableDeclaration}
* @implements {ScopedDeclaration}
* @implements {TypedDeclaration}
*/
export class MethodDeclaration implements
AbstractDeclaration,
AsyncDeclaration,
CallableDeclaration,
OptionalDeclaration,
ScopedDeclaration,
StaticDeclaration,
TypedDeclaration {
public parameters: ParameterDeclaration[] = [];
public variables: VariableDeclaration[] = [];
constructor(
public name: string,
public isAbstract: boolean,
public visibility: DeclarationVisibility | undefined,
public type: string | undefined,
public isOptional: boolean,
public isStatic: boolean,
public isAsync: boolean,
public start?: number,
public end?: number,
) { }
}
================================================
FILE: src/declarations/ModuleDeclaration.ts
================================================
import { Declaration } from './Declaration';
/**
* Module (namespace) declaration. Does export a whole module or namespace that is mainly used by
* external declaration files.
*
* @export
* @class ModuleDeclaration
* @implements {Declaration}
*/
export class ModuleDeclaration implements Declaration {
constructor(
public name: string,
public start?: number,
public end?: number,
) { }
}
================================================
FILE: src/declarations/ParameterDeclaration.ts
================================================
import { TypedDeclaration } from './Declaration';
/**
* Parameter declaration. Is contained in a method or function delaration since a parameter can not be exported
* by itself.
*
* @export
* @class ParameterDeclaration
* @implements {TypedDeclaration}
*/
export class ParameterDeclaration implements TypedDeclaration {
constructor(public name: string, public type: string | undefined, public start?: number, public end?: number) { }
}
export class BoundParameterDeclaration extends ParameterDeclaration {
public parameters: ParameterDeclaration[] = [];
public typeReference: string | undefined;
public get name(): string {
return this.parameters.length ?
`${this.startCharacter} ${this.parameters.map(p => p.name).join(', ')} ${this.endCharacter}` :
this.startCharacter + this.endCharacter;
}
public set name(_: string) { }
public get type(): string {
return this.typeReference ||
this.parameters.length ?
`{ ${this.parameters.map(p => p.type).join(', ')} }` :
this.startCharacter + this.endCharacter;
}
public set type(_: string) { }
constructor(private startCharacter: string, private endCharacter: string, start?: number, end?: number) {
super('', '', start, end);
}
}
export class ObjectBoundParameterDeclaration extends BoundParameterDeclaration {
constructor(start?: number, end?: number) {
super('{', '}', start, end);
}
}
export class ArrayBoundParameterDeclaration extends BoundParameterDeclaration {
constructor(start?: number, end?: number) {
super('[', ']', start, end);
}
}
================================================
FILE: src/declarations/PropertyDeclaration.ts
================================================
import { OptionalDeclaration, ScopedDeclaration, StaticDeclaration, TypedDeclaration } from './Declaration';
import { DeclarationVisibility } from './DeclarationVisibility';
/**
* Property declaration that contains its visibility.
*
* @export
* @class PropertyDeclaration
* @implements {ScopedDeclaration}
* @implements {TypedDeclaration}
*/
export class PropertyDeclaration implements OptionalDeclaration, ScopedDeclaration, StaticDeclaration, TypedDeclaration {
constructor(
public name: string,
public visibility: DeclarationVisibility | undefined,
public type: string | undefined,
public isOptional: boolean,
public isStatic: boolean,
public start?: number,
public end?: number,
) { }
}
================================================
FILE: src/declarations/TypeAliasDeclaration.ts
================================================
import { ExportableDeclaration } from './Declaration';
/**
* Alias declaration that can be exported. Is used to defined types.
* (e.g. type Foobar = { name: string };)
*
* @export
* @class TypeAliasDeclaration
* @implements {ExportableDeclaration}
*/
export class TypeAliasDeclaration implements ExportableDeclaration {
constructor(
public name: string,
public isExported: boolean,
public start?: number,
public end?: number,
) { }
}
================================================
FILE: src/declarations/VariableDeclaration.ts
================================================
import { ExportableDeclaration, TypedDeclaration } from './Declaration';
/**
* Variable declaration. Is contained in a method or function, or can be exported.
*
* @export
* @class VariableDeclaration
* @implements {ExportableDeclaration}
* @implements {TypedDeclaration}
*/
export class VariableDeclaration implements ExportableDeclaration, TypedDeclaration {
constructor(
public name: string,
public isConst: boolean,
public isExported: boolean,
public type: string | undefined,
public start?: number,
public end?: number,
) { }
}
================================================
FILE: src/declarations/index.ts
================================================
export * from './AccessorDeclaration';
export * from './ClassDeclaration';
export * from './ConstructorDeclaration';
export * from './Declaration';
export * from './DeclarationInfo';
export * from './DeclarationVisibility';
export * from './DefaultDeclaration';
export * from './EnumDeclaration';
export * from './FunctionDeclaration';
export * from './InterfaceDeclaration';
export * from './MethodDeclaration';
export * from './ModuleDeclaration';
export * from './ParameterDeclaration';
export * from './PropertyDeclaration';
export * from './TypeAliasDeclaration';
export * from './VariableDeclaration';
================================================
FILE: src/errors/NotGeneratableYetError.ts
================================================
import { Generatable } from '../code-generators/TypescriptCodeGenerator';
/**
* Error that should be thrown, when a generatable is not yet able to be generated.
*
* @export
* @class NotGeneratableYetError
* @extends {Error}
*/
export class NotGeneratableYetError extends Error {
constructor(generatable: Generatable) {
super();
this.message = `The element "${generatable.constructor.name}" is not yet generatable.`;
}
}
================================================
FILE: src/exports/AllExport.ts
================================================
import { Export } from './Export';
/**
* Declares an all export (i.e. export * from ...).
*
* @export
* @class AllExport
* @implements {Export}
*/
export class AllExport implements Export {
constructor(public start: number, public end: number, public from: string) { }
}
================================================
FILE: src/exports/AssignedExport.ts
================================================
import { ExportableDeclaration } from '../declarations/Declaration';
import { Module } from '../resources/Module';
import { Namespace } from '../resources/Namespace';
import { Resource } from '../resources/Resource';
import { isExportableDeclaration } from '../type-guards/TypescriptHeroGuards';
import { Export } from './Export';
/**
* Declares an all export (i.e. export * from ...).
*
* @export
* @class AssignedExport
* @implements {Export}
*/
export class AssignedExport implements Export {
/**
* Returns a list of exported objects of this export.
* This returns a list of possible exportable declarations or further exported resources.
*
* @readonly
* @type {((ExportableDeclaration | Resource)[])}
* @memberof AssignedExport
*/
public get exported(): (ExportableDeclaration | Resource)[] {
return <(ExportableDeclaration | Resource)[]>[
...this.resource.declarations
.filter(o =>
isExportableDeclaration(o) && o.isExported && o.name === this.declarationIdentifier),
...this.resource.resources
.filter(o =>
(o instanceof Namespace || o instanceof Module) && o.name === this.declarationIdentifier),
];
}
constructor(
public start: number,
public end: number,
public declarationIdentifier: string,
private resource: Resource,
) { }
}
================================================
FILE: src/exports/Export.ts
================================================
import { Node } from '../Node';
/**
* Basic export interface. Defines an export in a document.
*
* @export
* @interface Export
* @extends {Node}
*/
export interface Export extends Node { }
================================================
FILE: src/exports/NamedExport.ts
================================================
import { SymbolSpecifier } from '../SymbolSpecifier';
import { Export } from './Export';
/**
* Declares a named export (i.e. export { Foobar } from ...).
*
* @export
* @class NamedExport
* @implements {Export}
*/
export class NamedExport implements Export {
public specifiers: SymbolSpecifier[] | undefined;
constructor(public start: number, public end: number, public from: string) { }
}
================================================
FILE: src/exports/index.ts
================================================
export * from './AllExport';
export * from './AssignedExport';
export * from './Export';
export * from './NamedExport';
================================================
FILE: src/imports/ExternalModuleImport.ts
================================================
import { AliasedImport } from './Import';
/**
* Alternative to the namespace import. Can be used by various libraries.
* (i.e. import foobar = require('foobar')).
*
* @export
* @class ExternalModuleImport
* @implements {AliasedImport}
*/
export class ExternalModuleImport implements AliasedImport {
public get isNew(): boolean {
return this.start === undefined || this.end === undefined;
}
constructor(public libraryName: string, public alias: string, public start?: number, public end?: number) { }
/**
* Clone the current import object.
*
* @returns {ExternalModuleImport}
*
* @memberof ExternalModuleImport
*/
public clone(): ExternalModuleImport {
return new ExternalModuleImport(this.libraryName, this.alias, this.start, this.end);
}
}
================================================
FILE: src/imports/Import.ts
================================================
import { Clonable } from '../clonable/Clonable';
import { Node } from '../Node';
/**
* Basic import interface. Defines an import in a document.
* If no start and end points are given, the import is considered "new".
*
* @export
* @interface Import
*/
export interface Import extends Clonable<Import>, Node {
/**
* Indicates if the given import is "new" or a parsed one.
*
* @type {boolean}
* @memberof Import
*/
readonly isNew: boolean;
/**
* The library name of the given import (This actually is the part after the import statement).
*
* @example "express"
*
* @type {string}
* @memberof Import
*/
libraryName: string;
}
/**
* Basic interface for aliased imports. Defines an alias for namespace imports and other aliased imports.
*
* @export
* @interface AliasedImport
* @extends {Import}
*/
export interface AliasedImport extends Import {
/**
* Alias for the given import. E.g. for a "* as ..." import.
*
* @type {string}
* @memberof AliasedImport
*/
alias: string;
}
================================================
FILE: src/imports/NamedImport.ts
================================================
import { SymbolSpecifier } from '../SymbolSpecifier';
import { Import } from './Import';
/**
* Basic typescript import (ES6 style). Does contain multiple symbols of a file and converts
* itself to a multiline import if the threshold is reached.
* Can also contain a default import part.
* (i.e. import {Foobar} from ...).
*
* @export
* @class NamedImport
* @implements {Import}
*/
export class NamedImport implements Import {
public specifiers: SymbolSpecifier[] = [];
public defaultAlias?: string;
public get isNew(): boolean {
return this.start === undefined || this.end === undefined;
}
constructor(public libraryName: string, public start?: number, public end?: number) { }
/**
* Clone the current import object.
*
* @returns {NamedImport}
*
* @memberof NamedImport
*/
public clone(): NamedImport {
const clone = new NamedImport(this.libraryName, this.start, this.end);
clone.specifiers = this.specifiers.map(o => o.clone());
clone.defaultAlias = this.defaultAlias;
return clone;
}
}
================================================
FILE: src/imports/NamespaceImport.ts
================================================
import { AliasedImport } from './Import';
/**
* Import that imports a whole namespace (i.e. import * as foobar from 'foobar';).
*
* @export
* @class TsNamespaceImport
* @implements {AliasedImport}
*/
export class NamespaceImport implements AliasedImport {
public get isNew(): boolean {
return this.start === undefined || this.end === undefined;
}
constructor(public libraryName: string, public alias: string, public start?: number, public end?: number) { }
/**
* Clone the current import object.
*
* @returns {NamespaceImport}
*
* @memberof NamespaceImport
*/
public clone(): NamespaceImport {
return new NamespaceImport(this.libraryName, this.alias, this.start, this.end);
}
}
================================================
FILE: src/imports/StringImport.ts
================================================
import { Import } from './Import';
/**
* Simple string import (i.e. import "reflect-metadata";).
*
* @export
* @class StringImport
* @implements {Import}
*/
export class StringImport implements Import {
public get isNew(): boolean {
return this.start === undefined || this.end === undefined;
}
constructor(public libraryName: string, public start?: number, public end?: number) { }
/**
* Clone the current import object.
*
* @returns {StringImport}
*
* @memberof StringImport
*/
public clone(): StringImport {
return new StringImport(this.libraryName, this.start, this.end);
}
}
================================================
FILE: src/imports/index.ts
================================================
export * from './ExternalModuleImport';
export * from './Import';
export * from './NamedImport';
export * from './NamespaceImport';
export * from './StringImport';
================================================
FILE: src/index.ts
================================================
export * from './TypescriptParser';
export * from './Node';
export * from './SymbolSpecifier';
export * from './DeclarationIndex';
export * from './code-generators/TypescriptGenerationOptions';
export * from './code-generators/TypescriptCodeGenerator';
export * from './declarations';
export * from './exports';
export * from './imports';
export * from './resources';
export * from './type-guards/TypescriptHeroGuards';
================================================
FILE: src/node-parser/class-parser.ts
================================================
import {
ArrayBindingPattern,
ClassDeclaration,
ConstructorDeclaration,
Identifier,
Node,
ObjectBindingPattern,
SyntaxKind,
} from 'typescript';
import { GetterDeclaration, SetterDeclaration } from '../declarations/AccessorDeclaration';
import { ClassDeclaration as TshClass } from '../declarations/ClassDeclaration';
import { ConstructorDeclaration as TshConstructor } from '../declarations/ConstructorDeclaration';
import { DefaultDeclaration as TshDefault } from '../declarations/DefaultDeclaration';
import { MethodDeclaration as TshMethod } from '../declarations/MethodDeclaration';
import { ParameterDeclaration as TshParameter } from '../declarations/ParameterDeclaration';
import { PropertyDeclaration as TshProperty } from '../declarations/PropertyDeclaration';
import { Resource } from '../resources/Resource';
import {
isArrayBindingPattern,
isConstructorDeclaration,
isGetAccessorDeclaration,
isIdentifier,
isMethodDeclaration,
isObjectBindingPattern,
isPropertyDeclaration,
isSetAccessorDeclaration,
} from '../type-guards/TypescriptGuards';
import { parseFunctionParts, parseMethodParams } from './function-parser';
import { parseIdentifier } from './identifier-parser';
import {
containsModifier,
getDefaultResourceIdentifier,
getNodeType,
getNodeVisibility,
isNodeDefaultExported,
isNodeExported,
} from './parse-utilities';
/**
* Parses the identifiers of a class (usages).
*
* @export
* @param {Resource} tsResource
* @param {Node} node
*/
export function parseClassIdentifiers(tsResource: Resource, node: Node): void {
for (const child of node.getChildren()) {
switch (child.kind) {
case SyntaxKind.Identifier:
parseIdentifier(tsResource, <Identifier>child);
break;
default:
break;
}
parseClassIdentifiers(tsResource, child);
}
}
/**
* Parse information about a constructor. Contains parameters and used modifiers
* (i.e. constructor(private name: string)).
*
* @export
* @param {TshClass} parent
* @param {TshConstructor} ctor
* @param {ConstructorDeclaration} node
*/
export function parseCtorParams(
parent: TshClass,
ctor: TshConstructor,
node: ConstructorDeclaration,
): void {
if (!node.parameters) {
return;
}
node.parameters.forEach((o) => {
if (isIdentifier(o.name)) {
ctor.parameters.push(
new TshParameter(
(o.name as Identifier).text, getNodeType(o.type), o.getStart(), o.getEnd(),
),
);
if (!o.modifiers) {
return;
}
parent.properties.push(
new TshProperty(
(o.name as Identifier).text,
getNodeVisibility(o),
getNodeType(o.type),
!!o.questionToken,
containsModifier(o, SyntaxKind.StaticKeyword),
o.getStart(),
o.getEnd(),
),
);
} else if (isObjectBindingPattern(o.name) || isArrayBindingPattern(o.name)) {
const identifiers = o.name as ObjectBindingPattern | ArrayBindingPattern;
const elements = [...identifiers.elements];
// TODO: BindingElement
ctor.parameters = ctor.parameters.concat(<TshParameter[]>elements.map((bind: any) => {
if (isIdentifier(bind.name)) {
return new TshParameter(
(bind.name as Identifier).text, undefined, bind.getStart(), bind.getEnd(),
);
}
}).filter(Boolean));
}
});
}
/**
* Parses a class node into its declaration. Calculates the properties, constructors and methods of the class.
*
* @export
* @param {Resource} tsResource
* @param {ClassDeclaration} node
*/
export function parseClass(tsResource: Resource, node: ClassDeclaration): void {
const name = node.name ? node.name.text : getDefaultResourceIdentifier(tsResource);
const classDeclaration = new TshClass(name, isNodeExported(node), node.getStart(), node.getEnd());
if (isNodeDefaultExported(node)) {
classDeclaration.isExported = false;
tsResource.declarations.push(new TshDefault(classDeclaration.name, tsResource));
}
if (node.typeParameters) {
classDeclaration.typeParameters = node.typeParameters.map(param => param.getText());
}
if (node.members) {
node.members.forEach((o) => {
if (isPropertyDeclaration(o)) {
const actualCount = classDeclaration.properties.length;
if (o.modifiers) {
classDeclaration.properties.push(
new TshProperty(
(o.name as Identifier).text,
getNodeVisibility(o),
getNodeType(o.type),
!!o.questionToken,
containsModifier(o, SyntaxKind.StaticKeyword),
o.getStart(),
o.getEnd(),
),
);
}
if (actualCount === classDeclaration.properties.length) {
classDeclaration.properties.push(
new TshProperty(
(o.name as Identifier).text,
getNodeVisibility(o),
getNodeType(o.type),
!!o.questionToken,
containsModifier(o, SyntaxKind.StaticKeyword),
o.getStart(),
o.getEnd(),
),
);
}
return;
}
if (isGetAccessorDeclaration(o)) {
classDeclaration.accessors.push(
new GetterDeclaration(
(o.name as Identifier).text,
getNodeVisibility(o),
getNodeType(o.type),
o.modifiers !== undefined && o.modifiers.some(m => m.kind === SyntaxKind.AbstractKeyword),
containsModifier(o, SyntaxKind.StaticKeyword),
o.getStart(),
o.getEnd(),
),
);
}
if (isSetAccessorDeclaration(o)) {
classDeclaration.accessors.push(
new SetterDeclaration(
(o.name as Identifier).text,
getNodeVisibility(o),
getNodeType(o.type),
o.modifiers !== undefined && o.modifiers.some(m => m.kind === SyntaxKind.AbstractKeyword),
containsModifier(o, SyntaxKind.StaticKeyword),
o.getStart(),
o.getEnd(),
),
);
}
if (isConstructorDeclaration(o)) {
const ctor = new TshConstructor(classDeclaration.name, o.getStart(), o.getEnd());
parseCtorParams(classDeclaration, ctor, o);
classDeclaration.ctor = ctor;
parseFunctionParts(tsResource, ctor, o);
} else if (isMethodDeclaration(o)) {
const method = new TshMethod(
(o.name as Identifier).text,
o.modifiers !== undefined && o.modifiers.some(m => m.kind === SyntaxKind.AbstractKeyword),
getNodeVisibility(o),
getNodeType(o.type),
!!o.questionToken,
containsModifier(o, SyntaxKind.StaticKeyword),
containsModifier(o, SyntaxKind.AsyncKeyword),
o.getStart(),
o.getEnd(),
);
method.parameters = parseMethodParams(o);
classDeclaration.methods.push(method);
parseFunctionParts(tsResource, method, o);
}
});
}
parseClassIdentifiers(tsResource, node);
tsResource.declarations.push(classDeclaration);
}
================================================
FILE: src/node-parser/enum-parser.ts
================================================
import { EnumDeclaration } from 'typescript';
import { EnumDeclaration as TshEnum } from '../declarations/EnumDeclaration';
import { Resource } from '../resources/Resource';
import { isNodeExported } from './parse-utilities';
/**
* Parses an enum node into the declaration.
*
* @export
* @param {resource} resource
* @param {EnumDeclaration} node
*/
export function parseEnum(resource: Resource, node: EnumDeclaration): void {
const declaration = new TshEnum(
node.name.text, isNodeExported(node), node.getStart(), node.getEnd(),
);
declaration.members = node.members.map(o => o.name.getText());
resource.declarations.push(declaration);
}
================================================
FILE: src/node-parser/export-parser.ts
================================================
import { ExportAssignment, ExportDeclaration, Identifier, StringLiteral } from 'typescript';
import { DefaultDeclaration } from '../declarations/DefaultDeclaration';
import { AllExport } from '../exports/AllExport';
import { AssignedExport } from '../exports/AssignedExport';
import { NamedExport } from '../exports/NamedExport';
import { Resource } from '../resources/Resource';
import { SymbolSpecifier } from '../SymbolSpecifier';
import { isExportDeclaration, isNamedExports, isStringLiteral } from '../type-guards/TypescriptGuards';
import { getDefaultResourceIdentifier } from './parse-utilities';
/**
* Parses an export node into the declaration.
*
* @export
* @param {Resource} resource
* @param {(ExportDeclaration | ExportAssignment)} node
*/
export function parseExport(resource: Resource, node: ExportDeclaration | ExportAssignment): void {
if (isExportDeclaration(node)) {
const tsExport = node as ExportDeclaration;
if (!isStringLiteral(tsExport.moduleSpecifier) && !tsExport.exportClause) {
return;
}
if (tsExport.getText().indexOf('*') > -1) {
resource.exports.push(
new AllExport(
node.getStart(), node.getEnd(), (tsExport.moduleSpecifier as StringLiteral).text,
),
);
} else if (tsExport.exportClause && isNamedExports(tsExport.exportClause)) {
const lib = tsExport.moduleSpecifier as StringLiteral;
const ex = new NamedExport(
node.getStart(),
node.getEnd(),
lib ? lib.text : getDefaultResourceIdentifier(resource),
);
ex.specifiers = tsExport.exportClause.elements.map(
o => o.propertyName && o.name ?
new SymbolSpecifier(o.propertyName.text, o.name.text) :
new SymbolSpecifier(o.name.text),
);
for (const spec of ex.specifiers) {
if (resource.usages.indexOf(spec.alias || spec.specifier) === -1) {
resource.usages.push(spec.alias || spec.specifier);
}
}
resource.exports.push(ex);
}
} else {
const literal = node.expression as Identifier;
if (node.isExportEquals) {
resource.exports.push(new AssignedExport(node.getStart(), node.getEnd(), literal.text, resource));
if (resource.usages.indexOf(literal.text) === -1) {
resource.usages.push(literal.text);
}
} else {
const name = (literal && literal.text) ? literal.text : getDefaultResourceIdentifier(resource);
if (resource.usages.indexOf(name) === -1) {
resource.usages.push(name);
}
resource.declarations.push(new DefaultDeclaration(name, resource));
}
}
}
================================================
FILE: src/node-parser/function-parser.ts
================================================
import {
FunctionDeclaration,
Identifier,
isTupleTypeNode,
isTypeLiteralNode,
isTypeReferenceNode,
MethodDeclaration,
MethodSignature,
Node,
ParameterDeclaration,
PropertySignature,
SyntaxKind,
VariableStatement,
} from 'typescript';
import { ConstructorDeclaration as TshConstructor } from '../declarations/ConstructorDeclaration';
import { DefaultDeclaration as TshDefault } from '../declarations/DefaultDeclaration';
import { FunctionDeclaration as TshFunction } from '../declarations/FunctionDeclaration';
import { MethodDeclaration as TshMethod } from '../declarations/MethodDeclaration';
import {
ArrayBoundParameterDeclaration,
ObjectBoundParameterDeclaration,
ParameterDeclaration as TshParameter,
} from '../declarations/ParameterDeclaration';
import { Resource } from '../resources/Resource';
import {
isArrayBindingPattern,
isIdentifier,
isObjectBindingPattern,
isPropertySignature,
} from '../type-guards/TypescriptGuards';
import { parseIdentifier } from './identifier-parser';
import {
containsModifier,
getDefaultResourceIdentifier,
getNodeType,
isNodeDefaultExported,
isNodeExported,
} from './parse-utilities';
import { parseVariable } from './variable-parser';
/**
* Parse the parts of a function. All functions / methods contain various information about used variables
* and parameters.
*
* @export
* @param {Resource} resource
* @param {(TshConstructor | TshMethod | TshFunction)} parent
* @param {Node} node
*/
export function parseFunctionParts(
resource: Resource,
parent: TshConstructor | TshMethod | TshFunction,
node: Node,
): void {
for (const child of node.getChildren()) {
switch (child.kind) {
case SyntaxKind.Identifier:
parseIdentifier(resource, <Identifier>child);
break;
case SyntaxKind.VariableStatement:
parseVariable(parent, <VariableStatement>child);
break;
default:
break;
}
parseFunctionParts(resource, parent, child);
}
}
/**
* Parse method parameters.
*
* @export
* @param {(FunctionDeclaration | MethodDeclaration | MethodSignature)} node
* @returns {TshParameter[]}
*/
export function parseMethodParams(
node: FunctionDeclaration | MethodDeclaration | MethodSignature,
): TshParameter[] {
return node.parameters.reduce(
(all: TshParameter[], cur: ParameterDeclaration) => {
const params = all;
if (isIdentifier(cur.name)) {
params.push(new TshParameter(
(cur.name as Identifier).text, getNodeType(cur.type), cur.getStart(), cur.getEnd(),
));
} else if (isObjectBindingPattern(cur.name)) {
const elements = cur.name.elements;
let types: (string | undefined)[] = [];
const boundParam = new ObjectBoundParameterDeclaration(cur.getStart(), cur.getEnd());
if (cur.type && isTypeReferenceNode(cur.type)) {
boundParam.typeReference = getNodeType(cur.type);
} else if (cur.type && isTypeLiteralNode(cur.type)) {
types = cur.type.members
.filter(member => isPropertySignature(member))
.map((signature: any) => getNodeType((signature as PropertySignature).type));
}
boundParam.parameters = elements.map((bindingElement, index) => new TshParameter(
bindingElement.name.getText(),
types[index],
bindingElement.getStart(),
bindingElement.getEnd(),
));
params.push(boundParam);
} else if (isArrayBindingPattern(cur.name)) {
const elements = cur.name.elements;
let types: (string | undefined)[] = [];
const boundParam = new ArrayBoundParameterDeclaration(cur.getStart(), cur.getEnd());
if (cur.type && isTypeReferenceNode(cur.type)) {
boundParam.typeReference = getNodeType(cur.type);
} else if (cur.type && isTupleTypeNode(cur.type)) {
types = cur.type.elementTypes.map(type => getNodeType(type));
}
boundParam.parameters = elements.map((bindingElement, index) => new TshParameter(
bindingElement.getText(),
types[index],
bindingElement.getStart(),
bindingElement.getEnd(),
));
params.push(boundParam);
}
return params;
},
[],
);
}
/**
* Parses a function into its declaration.
* Parses the functions sub information like parameters and variables.
*
* @export
* @param {Resource} resource
* @param {FunctionDeclaration} node
*/
export function parseFunction(resource: Resource, node: FunctionDeclaration): void {
const name = node.name ? node.name.text : getDefaultResourceIdentifier(resource);
const func = new TshFunction(
name,
isNodeExported(node),
containsModifier(node, SyntaxKind.AsyncKeyword),
getNodeType(node.type),
node.getStart(),
node.getEnd(),
);
if (isNodeDefaultExported(node)) {
func.isExported = false;
resource.declarations.push(new TshDefault(func.name, resource));
}
func.parameters = parseMethodParams(node);
resource.declarations.push(func);
parseFunctionParts(resource, func, node);
}
================================================
FILE: src/node-parser/identifier-parser.ts
================================================
import { Identifier, Node, SyntaxKind } from 'typescript';
import { Resource } from '../resources/Resource';
const usageNotAllowedParents = [
SyntaxKind.ImportEqualsDeclaration,
SyntaxKind.ImportSpecifier,
SyntaxKind.NamespaceImport,
SyntaxKind.ClassDeclaration,
SyntaxKind.ImportEqualsDeclaration,
SyntaxKind.ImportClause,
SyntaxKind.ImportDeclaration,
SyntaxKind.InterfaceDeclaration,
SyntaxKind.ExportDeclaration,
SyntaxKind.ExportSpecifier,
SyntaxKind.ImportSpecifier,
SyntaxKind.FunctionDeclaration,
SyntaxKind.EnumDeclaration,
SyntaxKind.TypeAliasDeclaration,
SyntaxKind.MethodDeclaration,
];
const usageAllowedIfLast = [
SyntaxKind.Parameter,
SyntaxKind.PropertyDeclaration,
SyntaxKind.VariableDeclaration,
SyntaxKind.BinaryExpression,
];
const usagePredicates: ((node: Node) => boolean)[] = [
(o: Node) => o.parent !== undefined && usageNotAllowedParents.indexOf(o.parent.kind) === -1,
allowedIfLastIdentifier,
allowedIfPropertyAccessFirst,
];
/**
* Predicate function to determine if the node is possible as a "usage".
* Checks for the node identifier to be the last of the identifier list.
*
* @param {Node} node
* @returns {boolean}
*/
function allowedIfLastIdentifier(node: Node): boolean {
if (!node.parent) {
return false;
}
if (usageAllowedIfLast.indexOf(node.parent.kind) === -1) {
return true;
}
const children = node.parent.getChildren().filter(o => o.kind === SyntaxKind.Identifier);
return children.length === 1 || children.indexOf(node) === 1;
}
/**
* Predicate function to determine if the node is possible as a "usage".
* Checks if the identifier is on the lefthand side of a property access.
*
* @param {Node} node
* @returns {boolean}
*/
function allowedIfPropertyAccessFirst(node: Node): boolean {
if (!node.parent) {
return false;
}
if (node.parent.kind !== SyntaxKind.PropertyAccessExpression) {
return true;
}
const children = node.parent.getChildren();
return children.indexOf(node) === 0;
}
/**
* Parses an identifier into a usage of a resource if the predicates are true.
*
* @export
* @param {Resource} resource
* @param {Identifier} node
*/
export function parseIdentifier(resource: Resource, node: Identifier): void {
if (node.parent && usagePredicates.every(predicate => predicate(node))) {
if (resource.usages.indexOf(node.text) === -1) {
resource.usages.push(node.text);
}
}
}
================================================
FILE: src/node-parser/import-parser.ts
================================================
import {
ExternalModuleReference,
Identifier,
ImportDeclaration,
ImportEqualsDeclaration,
NamedImports,
NamespaceImport as TsNamespaceImport,
StringLiteral,
} from 'typescript';
import { ExternalModuleImport } from '../imports/ExternalModuleImport';
import { NamedImport } from '../imports/NamedImport';
import { NamespaceImport } from '../imports/NamespaceImport';
import { StringImport } from '../imports/StringImport';
import { Resource } from '../resources/Resource';
import { SymbolSpecifier } from '../SymbolSpecifier';
import {
isExternalModuleReference,
isImportDeclaration,
isNamedImports,
isNamespaceImport,
isStringLiteral,
} from '../type-guards/TypescriptGuards';
/**
* Parses an import node into the declaration.
*
* @export
* @param {Resource} resource
* @param {(ImportDeclaration | ImportEqualsDeclaration)} node
*/
export function parseImport(resource: Resource, node: ImportDeclaration | ImportEqualsDeclaration): void {
if (isImportDeclaration(node)) {
if (node.importClause && isNamespaceImport(node.importClause.namedBindings)) {
const lib = node.moduleSpecifier as StringLiteral;
const alias = (node.importClause.namedBindings as TsNamespaceImport).name as Identifier;
resource.imports.push(new NamespaceImport(lib.text, alias.text, node.getStart(), node.getEnd()));
} else if (node.importClause && (isNamedImports(node.importClause.namedBindings) || node.importClause.name)) {
const lib = node.moduleSpecifier as StringLiteral;
const tsImport = new NamedImport(lib.text, node.getStart(), node.getEnd());
if (node.importClause.name) {
tsImport.defaultAlias = node.importClause.name.text;
}
if (node.importClause.namedBindings) {
const bindings = node.importClause.namedBindings as NamedImports;
tsImport.specifiers = bindings.elements.map(
o => o.propertyName && o.name ?
new SymbolSpecifier(o.propertyName.text, o.name.text) :
new SymbolSpecifier(o.name.text),
);
const defaultImport = tsImport.specifiers.find(imp => imp.specifier === 'default' && !!imp.alias);
if (defaultImport) {
tsImport.specifiers.splice(tsImport.specifiers.indexOf(defaultImport), 1);
tsImport.defaultAlias = defaultImport.alias;
}
}
resource.imports.push(tsImport);
} else if (node.moduleSpecifier && isStringLiteral(node.moduleSpecifier)) {
const lib = node.moduleSpecifier as StringLiteral;
resource.imports.push(new StringImport(lib.text, node.getStart(), node.getEnd()));
}
} else if (isExternalModuleReference(node.moduleReference)) {
const alias = node.name;
const lib = (node.moduleReference as ExternalModuleReference).expression as Identifier;
resource.imports.push(new ExternalModuleImport(lib.text, alias.text, node.getStart(), node.getEnd()));
}
}
================================================
FILE: src/node-parser/index.ts
================================================
// export * from './class-parser';
// export * from './enum-parser';
// export * from './export-parser';
// export * from './function-parser';
// export * from './identifier-parser';
// export * from './import-parser';
// export * from './interface-parser';
// export * from './module-parser';
// export * from './type-alias-parser';
// export * from './variable-parser';
================================================
FILE: src/node-parser/interface-parser.ts
================================================
import { Identifier, InterfaceDeclaration, SyntaxKind } from 'typescript';
import { DeclarationVisibility } from '../declarations/DeclarationVisibility';
import { DefaultDeclaration } from '../declarations/DefaultDeclaration';
import { InterfaceDeclaration as TshInterface } from '../declarations/InterfaceDeclaration';
import { MethodDeclaration } from '../declarations/MethodDeclaration';
import { PropertyDeclaration } from '../declarations/PropertyDeclaration';
import { Resource } from '../resources/Resource';
import { isMethodSignature, isPropertySignature } from '../type-guards/TypescriptGuards';
import { parseMethodParams } from './function-parser';
import {
containsModifier,
getDefaultResourceIdentifier,
getNodeType,
isNodeDefaultExported,
isNodeExported,
} from './parse-utilities';
/**
* Parses an interface node into its declaration.
* Calculates the property and method defintions of the interface as well.
*
* @export
* @param {Resource} resource
* @param {InterfaceDeclaration} node
*/
export function parseInterface(resource: Resource, node: InterfaceDeclaration): void {
const name = node.name ? node.name.text : getDefaultResourceIdentifier(resource);
const interfaceDeclaration = new TshInterface(
name, isNodeExported(node), node.getStart(), node.getEnd(),
);
if (isNodeDefaultExported(node)) {
interfaceDeclaration.isExported = false;
resource.declarations.push(new DefaultDeclaration(interfaceDeclaration.name, resource));
}
if (node.members) {
node.members.forEach((o) => {
if (isPropertySignature(o)) {
interfaceDeclaration.properties.push(
new PropertyDeclaration(
(o.name as Identifier).text,
DeclarationVisibility.Public,
getNodeType(o.type),
!!o.questionToken,
containsModifier(o, SyntaxKind.StaticKeyword),
o.getStart(),
o.getEnd(),
),
);
} else if (isMethodSignature(o)) {
const method = new MethodDeclaration(
(o.name as Identifier).text,
true,
DeclarationVisibility.Public,
getNodeType(o.type),
!!o.questionToken,
containsModifier(o, SyntaxKind.StaticKeyword),
containsModifier(o, SyntaxKind.AsyncKeyword),
o.getStart(),
o.getEnd(),
);
method.parameters = parseMethodParams(o);
interfaceDeclaration.methods.push(method);
}
});
}
if (node.typeParameters) {
interfaceDeclaration.typeParameters = node.typeParameters.map(param => param.getText());
}
resource.declarations.push(interfaceDeclaration);
}
================================================
FILE: src/node-parser/module-parser.ts
================================================
import { Identifier, ModuleDeclaration, NodeFlags } from 'typescript';
import { Module } from '../resources/Module';
import { Namespace } from '../resources/Namespace';
import { Resource } from '../resources/Resource';
/**
* Parse a module to its declaration. Create a new namespace or module declaration and return it to
* be used as the new "container".
*
* @export
* @param {Resource} resource
* @param {ModuleDeclaration} node
* @returns {Resource}
*/
export function parseModule(resource: Resource, node: ModuleDeclaration): Resource {
const newResource = (node.flags & NodeFlags.Namespace) === NodeFlags.Namespace ?
new Namespace((node.name as Identifier).text, node.getStart(), node.getEnd()) :
new Module((node.name as Identifier).text, node.getStart(), node.getEnd());
resource.resources.push(newResource);
return newResource;
}
================================================
FILE: src/node-parser/parse-utilities.ts
================================================
import { Declaration, getCombinedModifierFlags, ModifierFlags, Node, SyntaxKind, TypeNode } from 'typescript';
import { DeclarationVisibility } from '../declarations/DeclarationVisibility';
import { File } from '../resources/File';
import { Resource } from '../resources/Resource';
/**
* Checks if the given typescript node has the exported flag.
* (e.g. export class Foobar).
*
* @export
* @param {Node} node
* @returns {boolean}
*/
export function isNodeExported(node: Node): boolean {
const flags = getCombinedModifierFlags(node as Declaration);
return (flags & ModifierFlags.Export) === ModifierFlags.Export;
}
/**
* Checks if the given typescript node has the default flag.
* (e.g. export default class Foobar).
*
* @export
* @param {Node} node
* @returns {boolean}
*/
export function isNodeDefaultExported(node: Node): boolean {
const flags = getCombinedModifierFlags(node as Declaration);
return (flags & ModifierFlags.Default) === ModifierFlags.Default;
}
/**
* Returns the type text (type information) for a given node.
*
* @export
* @param {(TypeNode | undefined)} node
* @returns {(string | undefined)}
*/
export function getNodeType(node: TypeNode | undefined): string | undefined {
return node ? node.getText() : undefined;
}
/**
* Checks if a node contains a certain modifier (of a given kind)
*
* @export
* @param {Node} node
* @param {SyntaxKind} modifierKind
* @returns {boolean}
*/
export function containsModifier(node: Node, modifierKind: SyntaxKind): boolean {
if (!node.modifiers) return false;
return node.modifiers.some(mod => mod.kind === modifierKind);
}
/**
* Returns the enum value (visibility) of a node.
*
* @export
* @param {Node} node
* @returns {(DeclarationVisibility | undefined)}
*/
export function getNodeVisibility(node: Node): DeclarationVisibility | undefined {
if (!node.modifiers) {
return undefined;
}
for (const modifier of node.modifiers) {
switch (modifier.kind) {
case SyntaxKind.PublicKeyword:
return DeclarationVisibility.Public;
case SyntaxKind.ProtectedKeyword:
return DeclarationVisibility.Protected;
case SyntaxKind.PrivateKeyword:
return DeclarationVisibility.Private;
default:
break;
}
}
}
/**
* Function that calculates the default name of a resource.
* This is used when a default export has no name (i.e. export class {}).
*
* @export
* @param {TsResource} resource
* @returns {string}
*/
export function getDefaultResourceIdentifier(resource: Resource): string {
if (resource instanceof File && resource.isWorkspaceFile) {
return resource.parsedPath.name;
}
return resource.identifier;
}
================================================
FILE: src/node-parser/traverse-ast.ts
================================================
export function traverseAst(root: Node, visit: (node: Node) => void, skipContents?: (node: Node) => boolean): void {
const stack = (root as any).getChildren();
for (let node = stack.shift(); node !== undefined; node = stack.shift()) {
visit(node);
if (skipContents && skipContents(node)) {
continue;
}
stack.unshift(...node.getChildren());
}
}
================================================
FILE: src/node-parser/type-alias-parser.ts
================================================
import { TypeAliasDeclaration } from 'typescript';
import { TypeAliasDeclaration as TshType } from '../declarations/TypeAliasDeclaration';
import { Resource } from '../resources/Resource';
import { isNodeExported } from './parse-utilities';
/**
* Parses a type alias into the declaration.
*
* @export
* @param {Resource} resource
* @param {TypeAliasDeclaration} node
*/
export function parseTypeAlias(resource: Resource, node: TypeAliasDeclaration): void {
resource.declarations.push(
new TshType(node.name.text, isNodeExported(node), node.getStart(), node.getEnd()),
);
}
================================================
FILE: src/node-parser/variable-parser.ts
================================================
import { SyntaxKind, VariableStatement } from 'typescript';
import { CallableDeclaration } from '../declarations/Declaration';
import { VariableDeclaration } from '../declarations/VariableDeclaration';
import { Resource } from '../resources/Resource';
import { isCallableDeclaration } from '../type-guards/TypescriptHeroGuards';
import { getNodeType, isNodeExported } from './parse-utilities';
/**
* Parse a variable. Information such as "is the variable const" are calculated here.
*
* @export
* @param {(Resource | CallableDeclaration)} parent
* @param {VariableStatement} node
*/
export function parseVariable(parent: Resource | CallableDeclaration, node: VariableStatement): void {
const isConst = node.declarationList.getChildren().some(o => o.kind === SyntaxKind.ConstKeyword);
if (node.declarationList && node.declarationList.declarations) {
node.declarationList.declarations.forEach((o) => {
const declaration = new VariableDeclaration(
o.name.getText(),
isConst,
isNodeExported(node),
getNodeType(o.type),
node.getStart(),
node.getEnd(),
);
if (isCallableDeclaration(parent)) {
parent.variables.push(declaration);
} else {
parent.declarations.push(declaration);
}
});
}
}
================================================
FILE: src/resources/File.ts
================================================
import { parse, ParsedPath, relative } from 'path';
import { Declaration } from '../declarations/Declaration';
import { Export } from '../exports/Export';
import { Import } from '../imports/Import';
import { Node } from '../Node';
import { normalizeFilename } from '../utilities/PathHelpers';
import { Module } from './Module';
import { Namespace } from './Namespace';
import { Resource } from './Resource';
/**
* TypeScript resource. Basically a file that is located somewhere.
*
* @export
* @class File
* @implements {Resource}
* @implements {Node}
*/
export class File implements Resource, Node {
public imports: Import[] = [];
public exports: Export[] = [];
public declarations: Declaration[] = [];
public resources: Resource[] = [];
public usages: string[] = [];
public get identifier(): string {
return '/' + normalizeFilename(relative(this.rootPath, this.filePath));
}
public get nonLocalUsages(): string[] {
return this.usages
.filter(usage =>
!this.declarations.some(o => o.name === usage) &&
!this.resources.some(o => (o instanceof Module || o instanceof Namespace) && o.name === usage),
)
.concat(
this.resources.reduce((all, cur) => all.concat(cur.nonLocalUsages), [] as string[]),
);
}
/**
* Returns the parsed path of a resource.
*
* @readonly
* @type {ParsedPath}
* @memberof File
*/
public get parsedPath(): ParsedPath {
return parse(this.filePath);
}
/**
* Determines if a file is a workspace file or an external resource.
*
* @readonly
* @type {boolean}
* @memberof File
*/
public get isWorkspaceFile(): boolean {
return ['node_modules', 'typings'].every(o => this.filePath.indexOf(o) === -1);
}
constructor(public filePath: string, private rootPath: string, public start: number, public end: number) { }
}
================================================
FILE: src/resources/Module.ts
================================================
import { Declaration } from '../declarations/Declaration';
import { Export } from '../exports/Export';
import { Import } from '../imports/Import';
import { Node } from '../Node';
import { Namespace } from './Namespace';
import { Resource } from './Resource';
/**
* TypeScript resource. Declaration of a typescript module (i.e. declare module "foobar").
*
* @export
* @class Module
* @implements {Resource}
* @implements {Node}
*/
export class Module implements Resource, Node {
public imports: Import[] = [];
public exports: Export[] = [];
public declarations: Declaration[] = [];
public resources: Resource[] = [];
public usages: string[] = [];
public get identifier(): string {
return this.name;
}
public get nonLocalUsages(): string[] {
return this.usages
.filter(usage =>
!this.declarations.some(o => o.name === usage) &&
!this.resources.some(o => (o instanceof Module || o instanceof Namespace) && o.name === usage))
.concat(
this.resources.reduce((all, cur) => all.concat(cur.nonLocalUsages), [] as string[]),
);
}
constructor(public name: string, public start: number, public end: number) { }
/**
* Function that calculates the alias name of a namespace.
* Removes all underlines and dashes and camelcases the name.
*
* @returns {string}
*
* @memberof Module
*/
public getNamespaceAlias(): string {
return this.name.split(/[-_]/).reduce(
(all, cur, idx) => {
if (idx === 0) {
return all + cur.toLowerCase();
}
return all + cur.charAt(0).toUpperCase() + cur.substring(1).toLowerCase();
},
'',
);
}
}
================================================
FILE: src/resources/Namespace.ts
================================================
import { Declaration } from '../declarations/Declaration';
import { Export } from '../exports/Export';
import { Import } from '../imports/Import';
import { Node } from '../Node';
import { Module } from './Module';
import { Resource } from './Resource';
/**
* TypeScript resource. Declaration of a typescript namespace (i.e. declare foobar).
*
* @export
* @class Namespace
* @implements {Resource}
* @implements {Node}
*/
export class Namespace implements Resource, Node {
public imports: Import[] = [];
public exports: Export[] = [];
public declarations: Declaration[] = [];
public resources: Resource[] = [];
public usages: string[] = [];
public get identifier(): string {
return this.name;
}
public get nonLocalUsages(): string[] {
return this.usages
.filter(usage =>
!this.declarations.some(o => o.name === usage) &&
!this.resources.some(o => (o instanceof Module || o instanceof Namespace) && o.name === usage))
.concat(
this.resources.reduce((all, cur) => all.concat(cur.nonLocalUsages), [] as string[]),
);
}
constructor(public name: string, public start: number, public end: number) { }
/**
* Function that calculates the alias name of a namespace.
* Removes all underlines and dashes and camelcases the name.
*
* @returns {string}
*
* @memberof Namespace
*/
public getNamespaceAlias(): string {
return this.name.split(/[-_]/).reduce(
(all, cur, idx) => {
if (idx === 0) {
return all + cur.toLowerCase();
}
return all + cur.charAt(0).toUpperCase() + cur.substring(1).toLowerCase();
},
'',
);
}
}
================================================
FILE: src/resources/Resource.ts
================================================
import { Declaration } from '../declarations/Declaration';
import { Export } from '../exports/Export';
import { Import } from '../imports/Import';
/**
* Base interface for resources. All resources share the same properties.
* Resources are files, namespaces or modules.
*
* @export
* @interface Resource
*/
export interface Resource {
/**
* List of imports contained in this resource.
*
* @type {Import[]}
* @memberof Resource
*/
imports: Import[];
/**
* List of exports contained in this resource.
*
* @type {Export[]}
* @memberof Resource
*/
exports: Export[];
/**
* List of declarations that are contained in this resource.
*
* @type {Declaration[]}
* @memberof Resource
*/
declarations: Declaration[];
/**
* List of subresources (like namespaces in a file) of this resource.
*
* @type {Resource[]}
* @memberof Resource
*/
resources: Resource[];
/**
* List of used identifiers in this resource.
* (i.e. actual used string identifiers to calculate missing imports and stuff.)
*
* @type {string[]}
* @memberof Resource
*/
usages: string[];
/**
* "Unique" identifier for this resource. Can be the filepath for files or
* node identifiers for node modules.
*
* @type {string}
* @memberof Resource
*/
readonly identifier: string;
/**
* Returns an array of usages (a usage is a used symbol name in the resource)
* that are not covered by its own declarations.
*
* @type {string[]}
* @memberof Resource
*/
readonly nonLocalUsages: string[];
}
================================================
FILE: src/resources/index.ts
================================================
export * from './File';
export * from './Module';
export * from './Namespace';
export * from './Resource';
================================================
FILE: src/type-guards/TypescriptGuards.ts
================================================
import {
ArrayBindingPattern,
ConstructorDeclaration,
ExportDeclaration,
ExternalModuleReference,
FunctionDeclaration,
GetAccessorDeclaration,
Identifier,
ImportDeclaration,
ImportEqualsDeclaration,
MethodDeclaration,
MethodSignature,
NamedExports,
NamedImports,
NamespaceImport,
Node,
ObjectBindingPattern,
PropertyDeclaration,
PropertySignature,
SetAccessorDeclaration,
StringLiteral,
SyntaxKind,
} from 'typescript';
/**
* Determines if the given node is an ImportDeclaration.
*
* @export
* @param {Node} [node]
* @returns {node is ImportDeclaration}
*/
export function isImportDeclaration(node?: Node): node is ImportDeclaration {
return node !== undefined && node.kind === SyntaxKind.ImportDeclaration;
}
/**
* Determines if the given node is an ImportEqualsDeclaration.
*
* @export
* @param {Node} [node]
* @returns {node is ImportEqualsDeclaration}
*/
export function isImportEqualsDeclaration(node?: Node): node is ImportEqualsDeclaration {
return node !== undefined && node.kind === SyntaxKind.ImportEqualsDeclaration;
}
/**
* Determines if the given node is a NamespaceImport.
*
* @export
* @param {Node} [node]
* @returns {node is NamespaceImport}
*/
export function isNamespaceImport(node?: Node): node is NamespaceImport {
return node !== undefined && node.kind === SyntaxKind.NamespaceImport;
}
/**
* Determines if the given node are NamedImports.
*
* @export
* @param {Node} [node]
* @returns {node is NamedImports}
*/
export function isNamedImports(node?: Node): node is NamedImports {
return node !== undefined && node.kind === SyntaxKind.NamedImports;
}
/**
* Determines if the given node are NamedExports.
*
* @export
* @param {Node} [node]
* @returns {node is NamedExports}
*/
export function isNamedExports(node?: Node): node is NamedExports {
return node !== undefined && node.kind === SyntaxKind.NamedExports;
}
/**
* Determines if the given node is a StringLiteral.
*
* @export
* @param {Node} [node]
* @returns {node is StringLiteral}
*/
export function isStringLiteral(node?: Node): node is StringLiteral {
return node !== undefined && node.kind === SyntaxKind.StringLiteral;
}
/**
* Determines if the given node is an Identifier.
*
* @export
* @param {Node} [node]
* @returns {node is Identifier}
*/
export function isIdentifier(node?: Node): node is Identifier {
return node !== undefined && node.kind === SyntaxKind.Identifier;
}
/**
* Determines if the given node is an ExternalModuleReference.
*
* @export
* @param {Node} [node]
* @returns {node is ExternalModuleReference}
*/
export function isExternalModuleReference(node?: Node): node is ExternalModuleReference {
return node !== undefined && node.kind === SyntaxKind.ExternalModuleReference;
}
/**
* Determines if the given node is an ExportDeclaration.
*
* @export
* @param {Node} [node]
* @returns {node is ExportDeclaration}
*/
export function isExportDeclaration(node?: Node): node is ExportDeclaration {
return node !== undefined && node.kind === SyntaxKind.ExportDeclaration;
}
/**
* Determines if the given node is an ObjectBindingPattern (i.e. let {x, y} = foo).
*
* @export
* @param {Node} [node]
* @returns {node is ObjectBindingPattern}
*/
export function isObjectBindingPattern(node?: Node): node is ObjectBindingPattern {
return node !== undefined && node.kind === SyntaxKind.ObjectBindingPattern;
}
/**
* Determines if the given node is an ArrayBindingPattern (i.e. let [x, y] = foo).
*
* @export
* @param {Node} [node]
* @returns {node is ArrayBindingPattern}
*/
export function isArrayBindingPattern(node?: Node): node is ArrayBindingPattern {
return node !== undefined && node.kind === SyntaxKind.ArrayBindingPattern;
}
/**
* Determines if the given node is a FunctionDeclaration.
*
* @export
* @param {Node} [node]
* @returns {node is FunctionDeclaration}
*/
export function isFunctionDeclaration(node?: Node): node is FunctionDeclaration {
return node !== undefined && node.kind === SyntaxKind.FunctionDeclaration;
}
/**
* Determines if the given node is a MethodSignature.
*
* @export
* @param {Node} [node]
* @returns {node is MethodSignature}
*/
export function isMethodSignature(node?: Node): node is MethodSignature {
return node !== undefined && node.kind === SyntaxKind.MethodSignature;
}
/**
* Determines if the given node is a PropertySignature.
*
* @export
* @param {Node} [node]
* @returns {node is PropertySignature}
*/
export function isPropertySignature(node?: Node): node is PropertySignature {
return node !== undefined && node.kind === SyntaxKind.PropertySignature;
}
/**
* Determines if the given node is a MethodDeclaration.
*
* @export
* @param {Node} [node]
* @returns {node is MethodDeclaration}
*/
export function isMethodDeclaration(node?: Node): node is MethodDeclaration {
return node !== undefined && node.kind === SyntaxKind.MethodDeclaration;
}
/**
* Determines if the given node is a PropertyDeclaration.
*
* @export
* @param {Node} [node]
* @returns {node is PropertyDeclaration}
*/
export function isPropertyDeclaration(node?: Node): node is PropertyDeclaration {
return node !== undefined && node.kind === SyntaxKind.PropertyDeclaration;
}
/**
* Determines if the given node is a ConstructorDeclaration.
*
* @export
* @param {Node} [node]
* @returns {node is ConstructorDeclaration}
*/
export function isConstructorDeclaration(node?: Node): node is ConstructorDeclaration {
return node !== undefined && node.kind === SyntaxKind.Constructor;
}
/**
* Determines if the given node is a isGetAccessorDeclaration.
*
* @export
* @param {Node} [node]
* @returns {node is isGetAccessorDeclaration}
*/
export function isGetAccessorDeclaration(node?: Node): node is GetAccessorDeclaration {
return node !== undefined && node.kind === SyntaxKind.GetAccessor;
}
/**
* Determines if the given node is a SetAccessorDeclaration.
*
* @export
* @param {Node} [node]
* @returns {node is SetAccessorDeclaration}
*/
export function isSetAccessorDeclaration(node?: Node): node is SetAccessorDeclaration {
return node !== undefined && node.kind === SyntaxKind.SetAccessor;
}
================================================
FILE: src/type-guards/TypescriptHeroGuards.ts
================================================
import { CallableDeclaration, ExportableDeclaration } from '../declarations/Declaration';
import { AliasedImport } from '../imports/Import';
/**
* Determines if the given object is a CallableDeclaration.
*
* @export
* @param {*} obj
* @returns {obj is CallableDeclaration}
*/
export function isCallableDeclaration(obj: any): obj is CallableDeclaration {
return obj && obj.parameters && obj.variables;
}
/**
* Determines if the given object is an ExportableDeclaration.
*
* @export
* @param {*} obj
* @returns {obj is ExportableDeclaration}
*/
export function isExportableDeclaration(obj: any): obj is ExportableDeclaration {
return obj && Object.keys(obj).indexOf('isExported') >= 0;
}
/**
* Determines if the given object is an AliasedImport.
*
* @export
* @param {*} obj
* @returns {obj is AliasedImport}
*/
export function isAliasedImport(obj: any): obj is AliasedImport {
return obj && Object.keys(obj).indexOf('alias') >= 0;
}
================================================
FILE: src/utilities/PathHelpers.ts
================================================
import { platform } from 'os';
/**
* Returns a normalized version of the a path uri. Removes a "file://" or "file:///" prefix and removes semicolons.
*
* @export
* @param {string} uri
* @returns {string}
*/
export function normalizePathUri(uri: string): string {
const decoded = decodeURIComponent(uri);
if (platform() === 'win32') {
return decoded.replace('file:///', '');
}
return decoded.replace('file://', '');
}
/**
* Returns an adjusted and normalized filepath to use within the index.
* Essentially does remove `.tsx` `.ts` `.js` `.jsx` endings and other adjustments.
*
* @export
* @param {string} filepath
* @returns {string}
*/
export function normalizeFilename(filepath: string): string {
return toPosix(filepath.replace(/([.]d)?[.](t|j)sx?$/g, ''));
}
/**
* On Windows, replaces all backslash delimeters with forward slashes.
* On other OSes, returns the path unmodified.
*/
export function toPosix(path: string): string {
if (platform() === 'win32') {
return path.replace(/\\/g, '/');
}
return path;
}
================================================
FILE: src/utilities/StringTemplate.ts
================================================
/**
* Creates a template from an expression string. The template can then be used to infuse stuff into the template.
*
* @export
* @param {string[]} strings
* @param {...number[]} keys
* @returns {(...values: any[]) => string}
*/
export function stringTemplate(strings: TemplateStringsArray, ...keys: number[]): (...values: any[]) => string {
return (...values: any[]) => {
const result = [strings[0]];
keys.forEach((key, idx) => {
result.push(values[key], strings[idx + 1]);
});
return result.join('');
};
}
================================================
FILE: test/SpecificUsageCases.spec.ts
================================================
import { TypescriptParser } from '../src';
import { getWorkspaceFile, rootPath } from './testUtilities';
describe('Specific usage cases', () => {
const parser = new TypescriptParser();
describe('i18next with and without destructure', () => {
it('should contain i18next reference in not destructured way', async () => {
const file = getWorkspaceFile('specific-usage-cases/i18next-destructure/import-my-component.tsx');
const parsed = await parser.parseFile(file, rootPath);
expect(parsed.usages).toMatchSnapshot();
});
it('should contain t reference in destructured way', async () => {
const file = getWorkspaceFile('specific-usage-cases/i18next-destructure/destructure-my-component.tsx');
const parsed = await parser.parseFile(file, rootPath);
expect(parsed.usages).toMatchSnapshot();
});
});
describe('get usage for directly reexported elements', () => {
it('should contain imported elements in usages', async () => {
const file = getWorkspaceFile('specific-usage-cases/reexport/reexport-import.ts');
const parsed = await parser.parseFile(file, rootPath);
expect(parsed.exports).toMatchSnapshot();
expect(parsed.usages).toMatchSnapshot();
});
it('should contain imported default elements in usages', async () => {
const file = getWorkspaceFile('specific-usage-cases/reexport/reexport-default.ts');
const parsed = await parser.parseFile(file, rootPath);
expect(parsed.exports).toMatchSnapshot();
expect(parsed.usages).toMatchSnapshot();
});
});
});
================================================
FILE: test/TypescriptParser.spec.ts
================================================
import { readFileSync } from 'fs';
import { ScriptKind } from 'typescript';
import { ClassDeclaration } from '../src/declarations/ClassDeclaration';
import { DeclarationVisibility } from '../src/declarations/DeclarationVisibility';
import { DefaultDeclaration } from '../src/declarations/DefaultDeclaration';
import { EnumDeclaration } from '../src/declarations/EnumDeclaration';
import { FunctionDeclaration } from '../src/declarations/FunctionDeclaration';
import { InterfaceDeclaration } from '../src/declarations/InterfaceDeclaration';
import { TypeAliasDeclaration } from '../src/declarations/TypeAliasDeclaration';
import { VariableDeclaration } from '../src/declarations/VariableDeclaration';
import { AllExport } from '../src/exports/AllExport';
import { AssignedExport } from '../src/exports/AssignedExport';
import { NamedExport } from '../src/exports/NamedExport';
import { ExternalModuleImport } from '../src/imports/ExternalModuleImport';
import { NamedImport } from '../src/imports/NamedImport';
import { NamespaceImport } from '../src/imports/NamespaceImport';
import { StringImport } from '../src/imports/StringImport';
import { File } from '../src/resources';
import { Module } from '../src/resources/Module';
import { Namespace } from '../src/resources/Namespace';
import { Resource } from '../src/resources/Resource';
import { TypescriptParser } from '../src/TypescriptParser';
import { getWorkspaceFile, rootPath } from './testUtilities';
describe('TypescriptParser', () => {
let parser: TypescriptParser;
beforeEach(() => {
parser = new TypescriptParser();
});
describe('Source parsing', () => {
it('should parse a source code string correctly', async () => {
const parsed = await parser.parseSource(`import {foo} from 'bar'; class Foobar {}; const bar = new Foobar();`);
expect(parsed).toMatchSnapshot();
});
});
describe('Import parsing', () => {
const file = getWorkspaceFile('typescript-parser/importsOnly.ts');
let parsed: Resource;
beforeEach(async () => {
parsed = await parser.parseFile(file, rootPath);
});
it('should parse imports', () => {
expect(parsed.imports).toHaveLength(12);
expect(parsed.imports).toMatchSnapshot();
});
it('should parse string import', () => {
expect(parsed.imports[0]).toBeInstanceOf(StringImport);
expect(parsed.imports[0]).toMatchSnapshot();
});
it('should parse named import', () => {
expect(parsed.imports[1]).toBeInstanceOf(NamedImport);
expect(parsed.imports[1]).toMatchSnapshot();
});
it('should parse named import with aliased specifier', () => {
expect(parsed.imports[2]).toBeInstanceOf(NamedImport);
expect(parsed.imports[2]).toMatchSnapshot();
});
it('should parse namespace import', () => {
expect(parsed.imports[3]).toBeInstanceOf(NamespaceImport);
expect(parsed.imports[3]).toMatchSnapshot();
});
it('should parse external module import', () => {
expect(parsed.imports[4]).toBeInstanceOf(ExternalModuleImport);
expect(parsed.imports[4]).toMatchSnapshot();
});
it('should parse a multiline import', () => {
expect(parsed.imports[5]).toBeInstanceOf(NamedImport);
expect(parsed.imports[5]).toMatchSnapshot();
});
it('should parse a default import', () => {
expect(parsed.imports[6]).toBeInstanceOf(NamedImport);
expect(parsed.imports[6]).toMatchSnapshot();
});
it('should not add any imports to the usages', () => {
expect(parsed.usages).toHaveLength(0);
});
it('should parse a named import with a default statement', () => {
expect(parsed.imports[7]).toBeInstanceOf(NamedImport);
expect(parsed.imports[7]).toMatchSnapshot();
});
it('should parse a mixed default / named import', () => {
expect(parsed.imports[8]).toBeInstanceOf(NamedImport);
expect(parsed.imports[8]).toMatchSnapshot();
});
it('should not parse a wrong default statement', async () => {
const wrong = await parser.parseSource(`import { default } from 'myLib';`);
expect(wrong).toBeInstanceOf(File);
expect(wrong).toMatchSnapshot();
});
});
describe('Export parsing', () => {
const file = getWorkspaceFile('typescript-parser/exportsOnly.ts');
let parsed: Resource;
beforeEach(async () => {
parsed = await parser.parseFile(file, rootPath);
});
it('should parse export all from another file', () => {
expect(parsed.exports[0]).toBeInstanceOf(AllExport);
expect(parsed.exports[0]).toMatchSnapshot();
});
it('should parse export named from another file', () => {
expect(parsed.exports[1]).toBeInstanceOf(NamedExport);
expect(parsed.exports[1]).toMatchSnapshot();
});
it('should parse aliased export named from another file', () => {
expect(parsed.exports[1]).toBeInstanceOf(NamedExport);
expect((parsed.exports[1] as NamedExport).specifiers[1]).toMatchSnapshot();
});
it('should parse export assignment', () => {
expect(parsed.exports[2]).toBeInstanceOf(AssignedExport);
delete (parsed.exports[2] as any).resource.filePath;
delete (parsed.exports[2] as any).resource.rootPath;
expect(parsed.exports[2]).toMatchSnapshot();
});
it('should parse default export', () => {
expect(parsed.declarations[0]).toBeInstanceOf(DefaultDeclaration);
delete (parsed.declarations[0] as any).resource.filePath;
delete (parsed.declarations[0] as any).resource.rootPath;
expect(parsed.declarations[0]).toMatchSnapshot();
});
});
describe('Declaration parsing', () => {
describe('Enums', () => {
const file = getWorkspaceFile('typescript-parser/enum.ts');
let parsed: Resource;
beforeEach(async () => {
parsed = await parser.parseFile(file, rootPath);
});
it('should parse a file', () => {
expect(parsed.declarations).toHaveLength(2);
});
it('should parse an enum correctly', () => {
expect(parsed.declarations[0]).toBeInstanceOf(EnumDeclaration);
expect(parsed.declarations[0]).toMatchSnapshot();
});
it('should parse an exported enum correctly', () => {
expect(parsed.declarations[1]).toBeInstanceOf(EnumDeclaration);
expect(parsed.declarations[1]).toMatchSnapshot();
});
});
describe('Type aliases', () => {
const file = getWorkspaceFile('typescript-parser/typeAlias.ts');
let parsed: Resource;
beforeEach(async () => {
parsed = await parser.parseFile(file, rootPath);
});
it('should parse a file', () => {
expect(parsed.declarations).toHaveLength(2);
});
it('should parse a type alias correctly', () => {
expect(parsed.declarations[0]).toBeInstanceOf(TypeAliasDeclaration);
expect(parsed.declarations[0]).toMatchSnapshot();
});
it('should parse an exported type alias correctly', () => {
expect(parsed.declarations[1]).toBeInstanceOf(TypeAliasDeclaration);
expect(parsed.declarations[1]).toMatchSnapshot();
});
});
describe('Functions', () => {
const file = getWorkspaceFile('typescript-parser/function.ts');
let parsed: Resource;
beforeEach(async () => {
parsed = await parser.parseFile(file, rootPath);
});
it('should parse a file', () => {
expect(parsed.declarations).toHaveLength(4);
});
it('should parse a function correctly', () => {
expect(parsed.declarations[0]).toBeInstanceOf(FunctionDeclaration);
expect(parsed.declarations[0]).toMatchSnapshot();
});
it('should parse an exported function correctly', () => {
expect(parsed.declarations[1]).toBeInstanceOf(FunctionDeclaration);
expect(parsed.declarations[1]).toMatchSnapshot();
});
it('should parse parameters correctly', () => {
expect((parsed.declarations[0] as FunctionDeclaration).parameters).toMatchSnapshot();
expect((parsed.declarations[1] as FunctionDeclaration).parameters).toMatchSnapshot();
});
it('should parse variables correctly', () => {
expect((parsed.declarations[0] as FunctionDeclaration).variables).toMatchSnapshot();
expect((parsed.declarations[1] as FunctionDeclaration).variables).toMatchSnapshot();
});
it('should parse return types correctly', () => {
expect((parsed.declarations[0] as FunctionDeclaration).type).toBe('string');
expect((parsed.declarations[1] as FunctionDeclaration).type).toBe('void');
expect((parsed.declarations[2] as FunctionDeclaration).type).toBeUndefined();
});
it('should parse a typeguard correctly', () => {
expect((parsed.declarations[3] as FunctionDeclaration).type).toBe('str is number');
});
});
describe('Parameters', () => {
const file = getWorkspaceFile('typescript-parser/parameters.ts');
let parsed: Resource;
beforeEach(async () => {
parsed = await parser.parseFile(file, rootPath);
});
it('should parse a normal parameter', () => {
const func = parsed.declarations[0] as FunctionDeclaration;
expect(func.parameters[0]).toMatchSnapshot();
});
it('should parse a simple array binding pattern', () => {
const func = parsed.declarations[1] as FunctionDeclaration;
expect(func.parameters[0]).toMatchSnapshot();
});
it('should parse an array with tuple type', () => {
const func = parsed.declarations[2] as FunctionDeclaration;
expect(func.parameters[0]).toMatchSnapshot();
});
it('should parse an array with undertyped tuple type', () => {
const func = parsed.declarations[3] as FunctionDeclaration;
expect(func.parameters[0]).toMatchSnapshot();
});
it('should parse an array with overtyped tuple type', () => {
const func = parsed.declarations[4] as FunctionDeclaration;
expect(func.parameters[0]).toMatchSnapshot();
});
it('should parse a simple object binding pattern ', () => {
const func = parsed.declarations[5] as FunctionDeclaration;
expect(func.parameters[0]).toMatchSnapshot();
});
it('should parse an object with type reference', () => {
const func = parsed.declarations[6] as FunctionDeclaration;
expect(func.parameters[0]).toMatchSnapshot();
});
it('should parse an object with type literal', () => {
const func = parsed.declarations[7] as FunctionDeclaration;
expect(func.parameters[0]).toMatchSnapshot();
});
it('should parse an object with undertyped type literal', () => {
const func = parsed.declarations[8] as FunctionDeclaration;
expect(func.parameters[0]).toMatchSnapshot();
});
it('should parse an object with overtyped type literal', () => {
const func = parsed.declarations[9] as FunctionDeclaration;
expect(func.parameters[0]).toMatchSnapshot();
});
it('should parse some mixed parameters (all above)', () => {
expect(parsed.declarations[10]).toMatchSnapshot();
});
it('should generate the correct name for an object', () => {
const func = parsed.declarations[9] as FunctionDeclaration;
expect(func.parameters[0].name).toMatchSnapshot();
});
it('should generate the correct name for an array', () => {
const func = parsed.declarations[2] as FunctionDeclaration;
expect(func.parameters[0].name).toMatchSnapshot();
});
it('should generate the correct type for an object', () => {
const func = parsed.declarations[9] as FunctionDeclaration;
expect(func.parameters[0].type).toMatchSnapshot();
});
it('should generate the correct type for an array', () => {
const func = parsed.declarations[2] as FunctionDeclaration;
expect(func.parameters[0].type).toMatchSnapshot();
});
});
describe('Variables', () => {
const file = getWorkspaceFile('typescript-parser/variable.ts');
let parsed: Resource;
beforeEach(async () => {
parsed = await parser.parseFile(file, rootPath);
});
it('should parse a file', () => {
expect(parsed.declarations).toHaveLength(7);
});
it('should parse a non exported variable', () => {
expect(parsed.declarations[0]).toBeInstanceOf(VariableDeclaration);
expect(parsed.declarations[0]).toMatchSnapshot();
});
it('should parse a non exported const', () => {
expect(parsed.declarations[1]).toBeInstanceOf(VariableDeclaration);
expect(parsed.declarations[1]).toMatchSnapshot();
});
it('should parse an exported variable', () => {
expect(parsed.declarations[2]).toBeInstanceOf(VariableDeclaration);
expect(parsed.declarations[2]).toMatchSnapshot();
});
it('should parse an exported const', () => {
expect(parsed.declarations[3]).toBeInstanceOf(VariableDeclaration);
expect(parsed.declarations[3]).toMatchSnapshot();
});
it('should parse an exported scope variable', () => {
expect(parsed.declarations[4]).toBeInstanceOf(VariableDeclaration);
expect(parsed.declarations[4]).toMatchSnapshot();
});
it('should parse an exported multiline variable', () => {
expect(parsed.declarations[5]).toBeInstanceOf(VariableDeclaration);
expect(parsed.declarations[5]).toMatchSnapshot();
expect(parsed.declarations[6]).toBeInstanceOf(VariableDeclaration);
expect(parsed.declarations[6]).toMatchSnapshot();
});
});
describe('Interfaces', () => {
const file = getWorkspaceFile('typescript-parser/interface.ts');
let parsed: Resource;
beforeEach(async () => {
parsed = await parser.parseFile(file, rootPath);
});
it('should parse a file', () => {
expect(parsed.declarations).toHaveLength(6);
});
it('should parse a non exported interface', () => {
expect(parsed.declarations[0]).toBeInstanceOf(InterfaceDeclaration);
expect(parsed.declarations[0]).toMatchSnapshot();
});
it('should parse an exported interface', () => {
expect(parsed.declarations[1]).toBeInstanceOf(InterfaceDeclaration);
expect(parsed.declarations[1]).toMatchSnapshot();
});
it('should parse the returntype of a method', () => {
const parsedInterface = parsed.declarations[0] as InterfaceDeclaration;
expect(parsedInterface.methods[0].type).toBeUndefined();
expect(parsedInterface.methods[1].type).toBe('void');
});
it('should parse the type of a property', () => {
const parsedInterface = parsed.declarations[1] as InterfaceDeclaration;
expect(parsedInterface.properties[0].type).toBe('string');
expect(parsedInterface.properties[1].type).toBe('number');
});
it('should parse a generic interface', () => {
const parsedInterface = parsed.declarations[2] as InterfaceDeclaration;
expect(parsedInterface.typeParameters).toContain('T');
});
it('should parse a generic interface with multiple type params', () => {
const parsedInterface = parsed.declarations[3] as InterfaceDeclaration;
expect(parsedInterface.typeParameters).toContain('TIn');
expect(parsedInterface.typeParameters).toContain('TOut');
expect(parsedInterface.typeParameters).toContain('TError');
});
it('should parse optional properties', () => {
const parsedInterface = parsed.declarations[4] as InterfaceDeclaration;
expect(parsedInterface.properties).toMatchSnapshot();
});
it('should parse optional functions', () => {
const parsedInterface = parsed.declarations[5] as InterfaceDeclaration;
expect(parsedInterface).toMatchSnapshot();
});
});
describe('Classes', () => {
const file = getWorkspaceFile('typescript-parser/class.ts');
let parsed: Resource;
beforeEach(async () => {
parsed = await parser.parseFile(file, rootPath);
});
it('should parse a file', () => {
expect(parsed.declarations).toHaveLength(10);
});
it('should parse an abstract class', () => {
expect(parsed.declarations[0]).toBeInstanceOf(ClassDeclaration);
expect(parsed.declarations[0]).toMatchSnapshot();
});
it('should parse a non exported class', () => {
expect(parsed.declarations[1]).toBeInstanceOf(ClassDeclaration);
expect(parsed.declarations[1]).toMatchSnapshot();
});
it('should parse an exported class', () => {
expect(parsed.declarations[2]).toBeInstanceOf(ClassDeclaration);
expect(parsed.declarations[2]).toMatchSnapshot();
});
it('should parse the returntype of a method', () => {
const parsedClass = parsed.declarations[0] as ClassDeclaration;
expect(parsedClass.methods[0].type).toBeUndefined();
expect(parsedClass.methods[1].type).toBe('void');
});
it('should parse the type of a property', () => {
const parsedClass = parsed.declarations[2] as ClassDeclaration;
expect(parsedClass.properties[0].type).toBe('string');
});
it('should parse the type of a constructor introduced property', () => {
const parsedClass = parsed.declarations[1] as ClassDeclaration;
expect(parsedClass.properties[0].type).toBe('string');
});
it('should parse a methods visibility', () => {
const parsedClass = parsed.declarations[1] as ClassDeclaration;
expect(parsedClass.methods[0].visibility).toBe(DeclarationVisibility.Public);
});
it('should parse a generic class', () => {
const parsedClass = parsed.declarations[3] as ClassDeclaration;
expect(parsedClass.typeParameters).toContain('T');
});
it('should parse a generic class with multiple type params', () => {
const parsedClass = parsed.declarations[4] as ClassDeclaration;
expect(parsedClass.typeParameters).toContain('TIn');
expect(parsedClass.typeParameters).toContain('TOut');
expect(parsedClass.typeParameters).toContain('TError');
});
it('should parse property accessors', () => {
const parsedClass = parsed.declarations[5] as ClassDeclaration;
expect(parsedClass.accessors).toMatchSnapshot();
});
it('should parse abstract property accessors', () => {
const parsedClass = parsed.declarations[6] as ClassDeclaration;
expect(parsedClass.accessors).toMatchSnapshot();
});
it('should parse object and array destructure pattern in a class method', () => {
const parsedClass = parsed.declarations[7] as ClassDeclaration;
expect(parsedClass.methods).toMatchSnapshot();
});
it('should parse object and array destructure pattern in a class constructor', () => {
const parsedClass = parsed.declarations[7] as ClassDeclaration;
expect(parsedClass.ctor).toMatchSnapshot();
});
it('should parse optional class properties', () => {
const parsedClass = parsed.declarations[8] as ClassDeclaration;
expect(parsedClass.properties).toMatchSnapshot();
});
it('should parse static class properties and methods', () => {
const parsedClass = parsed.declarations[9] as ClassDeclaration;
expect(parsedClass).toMatchSnapshot();
});
});
describe('Modules', () => {
const file = getWorkspaceFile('typescript-parser/module.ts');
let parsed: Resource;
beforeEach(async () => {
parsed = await parser.parseFile(file, rootPath);
});
it('should parse a file', () => {
expect(parsed.resources).toHaveLength(2);
});
it('should parse a module', () => {
expect(parsed.resources[0]).toBeInstanceOf(Module);
expect(parsed.resources[0]).toMatchSnapshot();
});
it('should parse a namespace', () => {
expect(parsed.resources[1]).toBeInstanceOf(Namespace);
expect(parsed.resources[1]).toMatchSnapshot();
});
});
});
describe('Usage parsing', () => {
const file = getWorkspaceFile('typescript-parser/usagesOnly.ts');
let parsed: Resource;
beforeEach(async () => {
parsed = await parser.parseFile(file, rootPath);
});
it('should parse decorator usages', () => {
const usages = parsed.usages;
expect(usages).toContain('ClassDecorator');
expect(usages).toContain('PropertyDecorator');
expect(usages).toContain('FunctionDecorator');
expect(usages).toContain('ParamDecorator');
});
it('should parse class member', () => {
const usages = parsed.usages;
expect(usages).toContain('notInitializedProperty');
expect(usages).toContain('typedProperty');
});
it('should parse class member types', () => {
const usages = parsed.usages;
expect(usages).toContain('TypedPropertyRef');
});
it('should parse class member assignment', () => {
const usages = parsed.usages;
expect(usages).toContain('AssignedProperty');
});
it('should parse params', () => {
const usages = parsed.usages;
expect(usages).toContain('param');
});
it('should parse param default assignment', () => {
const usages = parsed.usages;
expect(usages).toContain('DefaultParam');
});
it('should parse return value', () => {
const usages = parsed.usages;
expect(usages).toContain('ReturnValue');
});
it('should parse property access', () => {
const usages = parsed.usages;
expect(usages).toContain('PropertyAccess');
});
it('should not parse sub properties of accessed properties', () => {
const usages = parsed.usages;
expect(usages).not.toContain('To');
expect(usages).not.toContain('My');
expect(usages).not.toContain('Foobar');
});
it('should parse function call', () => {
const usages = parsed.usages;
expect(usages).toContain('functionCall');
expect(usages).toContain('MyProperty');
});
it('should parse indexer access', () => {
const usages = parsed.usages;
expect(usages).toContain('Indexing');
});
it('should parse variable assignment', () => {
const usages = parsed.usages;
expect(usages).toContain('AssignmentToVariable');
});
it('should parse nested identifier', () => {
const usages = parsed.usages;
expect(usages).toContain('NestedBinaryAssignment');
});
it('should parse a global (file level) used function', () => {
const usages = parsed.usages;
expect(usages).toContain('globalFunction');
});
it('should parse a global extended class', () => {
const usages = parsed.usages;
expect(usages).toContain('DefaultClass');
});
it('should parse a generic identifier in a class extension', () => {
const usages = parsed.usages;
expect(usages).toContain('GenericType');
});
it('should parse a default exported element', () => {
const usages = parsed.usages;
expect(usages).toContain('defaultExportUsage');
});
it('should parse an indexer property', () => {
const usages = parsed.usages;
expect(usages).toContain('indexedUsage');
});
it('should parse an indexer property access', () => {
const usages = parsed.usages;
expect(usages).toContain('indexingUsage');
});
});
describe('TSX Usage parsing', () => {
const file = getWorkspaceFile('typescript-parser/usagesOnly.tsx');
let parsed: Resource;
beforeEach(async () => {
parsed = await parser.parseFile(file, rootPath);
});
it('should parse a tsx element usage', () => {
const usages = parsed.usages;
expect(usages).toContain('myComponent');
expect(usages).toContain('div');
expect(usages).toContain('complexComp');
expect(usages).toContain('SingleComp');
});
it('should parse functions inside {}', () => {
const usages = parsed.usages;
expect(usages).toContain('myFunc');
});
it('should parse component functions inside {}', () => {
const usages = parsed.usages;
expect(usages).toContain('MyFunc');
});
it('should parse a component inside a map', () => {
const usages = parsed.usages;
expect(usages).toContain('AnotherComp');
expect(usages).toContain('foobarVariable');
});
it('should parse a function inside a map', () => {
const usages = parsed.usages;
expect(usages).toContain('valFunc');
});
it('should parseSource correctly', async () => {
const parsedSource = await parser.parseSource(readFileSync(file).toString(), ScriptKind.TSX);
expect(parsedSource.usages).toMatchSnapshot();
});
});
describe('TSX: Specific cases', () => {
const testFiles = [
{
filename: '1.tsx',
requiredUsages: [
'sortBy',
'Divider',
'Checkbox',
],
},
{
filename: '2.tsx',
requiredUsages: [
'ActionDelete',
'Divider',
'cloneDeep',
],
},
{
filename: '3.tsx',
requiredUsages: [
'ImageEdit',
'IconButton',
'TableHeaderColumn',
],
},
];
for (const testFile of testFiles) {
it('should parse the correct usages with "parseFile"', async () => {
const file = getWorkspaceFile(`typescript-parser/specific-cases/${testFile.filename}`);
const parsed = await parser.parseFile(file, rootPath);
for (const usage of testFile.requiredUsages) {
expect(parsed.usages).toContain(usage);
}
expect(parsed.usages).toMatchSnapshot();
});
it('should parse the correct usages with "parseFiles"', async () => {
const file = getWorkspaceFile(`typescript-parser/specific-cases/${testFile.filename}`);
const parsed = (await parser.parseFiles([file], rootPath))[0];
for (const usage of testFile.requiredUsages) {
expect(parsed.usages).toContain(usage);
}
expect(parsed.usages).toMatchSnapshot();
});
it('should parse the correct usages with "parseSource"', async () => {
const file = getWorkspaceFile(`typescript-parser/specific-cases/${testFile.filename}`);
const fileSource = readFileSync(file).toString();
const parsed = await parser.parseSource(fileSource, ScriptKind.TSX);
for (const usage of testFile.requiredUsages) {
expect(parsed.usages).toContain(usage);
}
expect(parsed.usages).toMatchSnapshot();
});
}
});
describe('JavaScript parsing', () => {
const file = getWorkspaceFile('typescript-parser/javascript.js');
it('should parse a simple javascript file correctly with "parseFile"', async () => {
const parsed = await parser.parseFile(file, rootPath);
delete parsed.filePath;
delete (parsed as any).rootPath;
expect(parsed).toMatchSnapshot();
});
it('should parse a simple javascript file correctly with "parseFiles"', async () => {
const parsed = await parser.parseFiles([file], rootPath);
delete parsed[0].filePath;
delete (parsed[0] as any).rootPath;
expect(parsed).toMatchSnapshot();
});
it('should parse a simple javascript file correctly with "parseSource"', async () => {
const content = readFileSync(file).toString();
const parsed = await parser.parseSource(content, ScriptKind.JS);
expect(parsed).toMatchSnapshot();
});
});
describe('JSX parsing', () => {
const file = getWorkspaceFile('typescript-parser/jsx.jsx');
it('should parse a simple javascript react file correctly with "parseFile"', async () => {
const parsed = await parser.parseFile(file, rootPath);
delete parsed.filePath;
delete (parsed as any).rootPath;
expect(parsed).toMatchSnapshot();
});
it('should parse a simple javascript react file correctly with "parseFiles"', async () => {
const parsed = await parser.parseFiles([file], rootPath);
delete parsed[0].filePath;
delete (parsed[0] as any).rootPath;
expect(parsed).toMatchSnapshot();
});
it('should parse a simple javascript react file correctly with "parseSource"', async () => {
const content = readFileSync(file).toString();
const parsed = await parser.parseSource(content, ScriptKind.JSX);
expect(parsed).toMatchSnapshot();
});
});
describe('Specific sources', () => {
it('should parse generics in functions in classes correctly', async () => {
const parsed = await parser.parseSource(
`export class TestClass {
public test() {
let a = <T>() => { let b = null; };
}
}`,
ScriptKind.TS,
);
expect(parsed).toMatchSnapshot();
});
});
describe('Parses Webpack Bundle', () => {
const file = getWorkspaceFile('typescript-parser/webpack-bundle.js');
it('should parse the whole webpack bundle', async () => {
await parser.parseFile(file, rootPath);
});
});
});
================================================
FILE: test/__snapshots__/SpecificUsageCases.spec.ts.snap
================================================
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Specific usage cases get usage for directly reexported elements should contain imported default elements in usages 1`] = `Array []`;
exports[`Specific usage cases get usage for directly reexported elements should contain imported default elements in usages 2`] = `
Array [
"Test",
]
`;
exports[`Specific usage cases get usage for directly reexported elements should contain imported elements in usages 1`] = `
Array [
NamedExport {
"end": 184,
"from": "reexport-import",
"specifiers": Array [
SymbolSpecifier {
"alias": undefined,
"specifier": "colors",
},
SymbolSpecifier {
"alias": undefined,
"specifier": "helpers",
},
SymbolSpecifier {
"alias": undefined,
"specifier": "theme",
},
SymbolSpecifier {
"alias": undefined,
"specifier": "icons",
},
],
"start": 143,
},
]
`;
exports[`Specific usage cases get usage for directly reexported elements should contain imported elements in usages 2`] = `
Array [
"colors",
"helpers",
"theme",
"icons",
]
`;
exports[`Specific usage cases i18next with and without destructure should contain i18next reference in not destructured way 1`] = `
Array [
"MyComponent",
"p",
"i18next",
]
`;
exports[`Specific usage cases i18next with and without destructure should contain t reference in destructured way 1`] = `
Array [
"MyComponent",
"p",
"t",
]
`;
================================================
FILE: test/__snapshots__/TypescriptParser.spec.ts.snap
================================================
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`TypescriptParser Declaration parsing Classes should parse a non exported class 1`] = `
ClassDeclaration {
"accessors": Array [],
"ctor": ConstructorDeclaration {
"end": 171,
"name": "NonExportedClass",
"parameters": Array [
ParameterDeclaration {
"end": 166,
"name": "param1",
"start": 145,
"type": "string",
},
],
"start": 133,
"variables": Array [],
},
"end": 302,
"isExported": false,
"methods": Array [
MethodDeclaration {
"end": 203,
"isAbstract": false,
"isAsync": false,
"isOptional": false,
"isStatic": false,
"name": "method1",
"parameters": Array [],
"start": 177,
"type": "void",
"variables": Array [],
"visibility": 2,
},
MethodDeclaration {
"end": 237,
"isAbstract": false,
"isAsync": false,
"isOptional": false,
"isStatic": false,
"name": "method2",
"parameters": Array [],
"start": 208,
"type": "void",
"variables": Array [],
"visibility": 1,
},
MethodDeclaration {
"end": 300,
"isAbstract": false,
"isAsync": false,
"isOptional": false,
"isStatic": false,
"name": "method3",
"parameters": Array [],
"start": 242,
"type": "void",
"variables": Array [
VariableDeclaration {
"end": 294,
"isConst": false,
"isExported": false,
"name": "variable",
"start": 276,
"type": undefined,
},
],
"visibility": 0,
},
],
"name": "NonExportedClass",
"properties": Array [
PropertyDeclaration {
"end": 166,
"isOptional": false,
"isStatic": false,
"name": "param1",
"start": 145,
"type": "string",
"visibility": 2,
},
],
"start": 104,
}
`;
exports[`TypescriptParser Declaration parsing Classes should parse abstract property accessors 1`] = `
Array [
GetterDeclaration {
"end": 977,
"isAbstract": true,
"isStatic": false,
"name": "getOnly",
"start": 939,
"type": "string",
"visibility": 2,
},
SetterDeclaration {
"end": 1022,
"isAbstract": true,
"isStatic": false,
"name": "setOnly",
"start": 982,
"type": undefined,
"visibility": 2,
},
GetterDeclaration {
"end": 1067,
"isAbstract": true,
"isStatic": false,
"name": "getAndSet",
"start": 1027,
"type": "string",
"visibility": 2,
},
SetterDeclaration {
"end": 1117,
"isAbstract": true,
"isStatic": false,
"name": "getAndSet",
"start": 1072,
"type": undefined,
"visibility": 2,
},
]
`;
exports[`TypescriptParser Declaration parsing Classes should parse an abstract class 1`] = `
ClassDeclaration {
"accessors": Array [],
"end": 102,
"isExported": false,
"methods": Array [
MethodDeclaration {
"end": 55,
"isAbstract": false,
"isAsync": false,
"isOptional": false,
"isStatic": false,
"name": "method1",
"parameters": Array [],
"start": 35,
"type": undefined,
"variables": Array [],
"visibility": 2,
},
MethodDeclaration {
"end": 100,
"isAbstract": true,
"isAsync": false,
"isOptional": false,
"isStatic": false,
"name": "abstractMethod",
"parameters": Array [],
"start": 61,
"type": "void",
"variables": Array [],
"visibility": 2,
},
],
"name": "AbstractClass",
"properties": Array [],
"start": 0,
}
`;
exports[`TypescriptParser Declaration parsing Classes should parse an exported class 1`] = `
ClassDeclaration {
"accessors": Array [
GetterDeclaration {
"end": 492,
"isAbstract": false,
"isStatic": false,
"name": "property",
"start": 424,
"type": "string",
"visibility": 2,
},
SetterDeclaration {
"end": 572,
"isAbstract": false,
"isStatic": false,
"name": "property",
"start": 498,
"type": undefined,
"visibility": 2,
},
],
"end": 574,
"isExported": true,
"methods": Array [],
"name": "ExportedClass",
"properties": Array [
PropertyDeclaration {
"end": 363,
"isOptional": false,
"isStatic": false,
"name": "_property",
"start": 337,
"type": "string",
"visibility": 0,
},
PropertyDeclaration {
"end": 394,
"isOptional": false,
"isStatic": false,
"name": "protect",
"start": 368,
"type": "string",
"visibility": 1,
},
PropertyDeclaration {
"end": 418,
"isOptional": false,
"isStatic": false,
"name": "pub",
"start": 399,
"type": "string",
"visibility": 2,
},
],
"start": 304,
}
`;
exports[`TypescriptParser Declaration parsing Classes should parse object and array destructure pattern in a class constructor 1`] = `
ConstructorDeclaration {
"end": 1198,
"name": "ObjAndArrDestruct",
"parameters": Array [
ParameterDeclaration {
"end": 1167,
"name": "p1",
"start": 1165,
"type": undefined,
},
ParameterDeclaration {
"end": 1171,
"name": "p2",
"start": 1169,
"type": undefined,
},
ParameterDeclaration {
"end": 1183,
"name": "p3",
"start": 1181,
"type": undefined,
},
ParameterDeclaration {
"end": 1187,
"name": "p4",
"start": 1185,
"type": undefined,
},
],
"start": 1151,
"variables": Array [],
}
`;
exports[`TypescriptParser Declaration parsing Classes should parse object and array destructure pattern in a class method 1`] = `
Array [
MethodDeclaration {
"end": 1251,
"isAbstract": false,
"isAsync": false,
"isOptional": false,
"isStatic": false,
"name": "objMethod",
"parameters": Array [
ObjectBoundParameterDeclaration {
"end": 1240,
"endCharacter": "}",
"parameters": Array [
ParameterDeclaration {
"end": 1225,
"name": "p1",
"start": 1223,
"type": undefined,
},
ParameterDeclaration {
"end": 1229,
"name": "p2",
"start": 1227,
"type": undefined,
},
ParameterDeclaration {
"end": 1233,
"name": "p3",
"start": 1231,
"type": undefined,
},
],
"start": 1221,
"startCharacter": "{",
},
],
"start": 1204,
"type": "void",
"variables": Array [],
"visibility": 2,
},
MethodDeclaration {
"end": 1307,
"isAbstract": false,
"isAsync": false,
"isOptional": false,
"isStatic": false,
"name": "arrMethod",
"parameters": Array [
ArrayBoundParameterDeclaration {
"end": 1296,
"endCharacter": "]",
"parameters": Array [
ParameterDeclaration {
"end": 1277,
"name": "p1",
"start": 1275,
"type": undefined,
},
ParameterDeclaration {
"end": 1281,
"name": "p2",
"start": 1279,
"type": undefined,
},
ParameterDeclaration {
"end": 1285,
"name": "p3",
"start": 1283,
"type": undefined,
},
],
"start": 1274,
"startCharacter": "[",
},
],
"start": 1257,
"type": "void",
"variables": Array [],
"visibility": 2,
},
MethodDeclaration {
"end": 1386,
"isAbstract": false,
"isAsync": false,
"isOptional": false,
"isStatic": false,
"name": "objAndArrMethod",
"parameters": Array [
ArrayBoundParameterDeclaration {
"end": 1358,
"endCharacter": "]",
"parameters": Array [
ParameterDeclaration {
"end": 1339,
"name": "p1",
"start": 1337,
"type": undefined,
},
ParameterDeclaration {
"end": 1343,
"name": "p2",
"start": 1341,
"type": undefined,
},
ParameterDeclaration {
"end": 1347,
"name": "p3",
"start": 1345,
"type": undefined,
},
],
"start": 1336,
"startCharacter": "[",
},
ObjectBoundParameterDeclaration {
"end": 1375,
"endCharacter": "}",
"parameters": Array [
ParameterDeclaration {
"end": 1364,
"name": "p4",
"start": 1362,
"type": undefined,
},
ParameterDeclaration {
"end": 1368,
"name": "p5",
"start": 1366,
"type": undefined,
},
],
"start": 1360,
"startCharacter": "{",
},
],
"start": 1313,
"type": "void",
"variables": Array [],
"visibility": 2,
},
]
`;
exports[`TypescriptParser Declaration parsing Classes should parse optional class properties 1`] = `
Array [
PropertyDeclaration {
"end": 1448,
"isOptional": false,
"isStatic": false,
"name": "nonOptional",
"start": 1421,
"type": "string",
"visibility": 2,
},
PropertyDeclaration {
"end": 1498,
"isOptional": false,
"isStatic": false,
"name": "nonOptionalAsWell",
"start": 1453,
"type": "string | undefined",
"visibility": 2,
},
PropertyDeclaration {
"end": 1528,
"isOptional": true,
"isStatic": false,
"name": "optional",
"start": 1503,
"type": "string",
"visibility": 2,
},
]
`;
exports[`TypescriptParser Declaration parsing Classes should parse property accessors 1`] = `
Array [
GetterDeclaration {
"end": 731,
"isAbstract": false,
"isStatic": false,
"name": "getOnly",
"start": 670,
"type": "string",
"visibility": 2,
},
SetterDeclaration {
"end": 775,
"isAbstract": false,
"isStatic": false,
"name": "setOnly",
"start": 737,
"type": undefined,
"visibility": 2,
},
GetterDeclaration {
"end": 838,
"isAbstract": false,
"isStatic": false,
"name": "getAndSet",
"start": 781,
"type": "string",
"visibility": 2,
},
SetterDeclaration {
"end": 888,
"isAbstract": false,
"isStatic": false,
"name": "getAndSet",
"start": 844,
"type": undefined,
"visibility": 2,
},
]
`;
exports[`TypescriptParser Declaration parsing Classes should parse static class properties and methods 1`] = `
ClassDeclaration {
"accessors": Array [],
"end": 1662,
"isExported": false,
"methods": Array [
MethodDeclaration {
"end": 1621,
"isAbstract": false,
"isAsync": false,
"isOptional": false,
"isStatic": true,
"name": "method",
"parameters": Array [],
"start": 1589,
"type": "void",
"variables": Array [],
"visibility": 2,
},
MethodDeclaration {
"end": 1660,
"isAbstract": false,
"isAsync": false,
"isOptional": false,
"isStatic": false,
"name": "methodNonStatic",
"parameters": Array [],
"start": 1626,
"type": "void",
"variables": Array [],
"visibility": 2,
},
],
"name": "StaticThings",
"properties": Array [
PropertyDeclaration {
"end": 1584,
"isOptional": false,
"isStatic": true,
"name": "prop",
"start": 1557,
"type": "string",
"visibility": 2,
},
],
"start": 1532,
}
`;
exports[`TypescriptParser Declaration parsing Enums should parse an enum correctly 1`] = `
EnumDeclaration {
"end": 58,
"isExported": false,
"members": Array [
"Member1",
"Member2",
"Member3",
],
"name": "Enumeration",
"start": 0,
}
`;
exports[`TypescriptParser Declaration parsing Enums should parse an exported enum correctly 1`] = `
EnumDeclaration {
"end": 136,
"isExported": true,
"members": Array [
"ConstMember1",
"ConstMember2",
],
"name": "ConstantEnumeration",
"start": 60,
}
`;
exports[`TypescriptParser Declaration parsing Functions should parse a function correctly 1`] = `
FunctionDeclaration {
"end": 84,
"isAsync": false,
"isExported": false,
"name": "function1",
"parameters": Array [
ParameterDeclaration {
"end": 25,
"name": "param1",
"start": 19,
"type": undefined,
},
],
"start": 0,
"type": "string",
"variables": Array [
VariableDeclaration {
"end": 61,
"isConst": false,
"isExported": false,
"name": "var1",
"start": 41,
"type": undefined,
},
],
}
`;
exports[`TypescriptParser Declaration parsing Functions should parse an exported function correctly 1`] = `
FunctionDeclaration {
"end": 219,
"isAsync": false,
"isExported": true,
"name": "function2",
"parameters": Array [
ParameterDeclaration {
"end": 126,
"name": "param1",
"start": 112,
"type": "string",
},
ObjectBoundParameterDeclaration {
"end": 152,
"endCharacter": "}",
"parameters": Array [
ParameterDeclaration {
"end": 139,
"name": "objParam1",
"start": 130,
"type": undefined,
},
ParameterDeclaration {
"end": 150,
"name": "objParam2",
"start": 141,
"type": undefined,
},
],
"start": 128,
"startCharacter": "{",
},
ArrayBoundParameterDeclaration {
"end": 176,
"endCharacter": "]",
"parameters": Array [
ParameterDeclaration {
"end": 164,
"name": "arrParam1",
"start": 155,
"type": undefined,
},
ParameterDeclaration {
"end": 175,
"name": "arrParam2",
"start": 166,
"type": undefined,
},
],
"start": 154,
"startCharacter": "[",
},
],
"start": 86,
"type": "void",
"variables": Array [
VariableDeclaration {
"end": 217,
"isConst": true,
"isExported": false,
"name": "constVar1",
"start": 190,
"type": undefined,
},
],
}
`;
exports[`TypescriptParser Declaration parsing Functions should parse parameters correctly 1`] = `
Array [
ParameterDeclaration {
"end": 25,
"name": "param1",
"start": 19,
"type": undefined,
},
]
`;
exports[`TypescriptParser Declaration parsing Functions should parse parameters correctly 2`] = `
Array [
ParameterDeclaration {
"end": 126,
"name": "param1",
"start": 112,
"type": "string",
},
ObjectBoundParameterDeclaration {
"end": 152,
"endCharacter": "}",
"parameters": Array [
ParameterDeclaration {
"end": 139,
"name": "objParam1",
"start": 130,
"type": undefined,
},
ParameterDeclaration {
"end": 150,
"name": "objParam2",
"start": 141,
"type": undefined,
},
],
"start": 128,
"startCharacter": "{",
},
ArrayBoundParameterDeclaration {
"end": 176,
"endCharacter": "]",
"parameters": Array [
ParameterDeclaration {
"end": 164,
"name": "arrParam1",
"start": 155,
"type": undefined,
},
ParameterDeclaration {
"end": 175,
"name": "arrParam2",
"start": 166,
"type": undefined,
},
],
"start": 154,
"startCharacter": "[",
},
]
`;
exports[`TypescriptParser Declaration parsing Functions should parse variables correctly 1`] = `
Array [
VariableDeclaration {
"end": 61,
"isConst": false,
"isExported": false,
"name": "var1",
"start": 41,
"type": undefined,
},
]
`;
exports[`TypescriptParser Declaration parsing Functions should parse variables correctly 2`] = `
Array [
VariableDeclaration {
"end": 217,
"isConst": true,
"isExported": false,
"name": "constVar1",
"start": 190,
"type": undefined,
},
]
`;
exports[`TypescriptParser Declaration parsing Interfaces should parse a non exported interface 1`] = `
InterfaceDeclaration {
"accessors": Array [],
"end": 130,
"isExported": false,
"methods": Array [
MethodDeclaration {
"end": 93,
"isAbstract": true,
"isAsync": false,
"isOptional": false,
"isStatic": false,
"name": "method1",
"parameters": Array [],
"start": 83,
"type": undefined,
"variables": Array [],
"visibility": 2,
},
MethodDeclaration {
"end": 128,
"isAbstract": true,
"isAsync": false,
"isOptional": false,
"isStatic": false,
"name": "method2",
"parameters": Array [
ParameterDeclaration {
"end": 120,
"name": "param1",
"start": 106,
"type": "string",
},
],
"start": 98,
"type": "void",
"variables": Array [],
"visibility": 2,
},
],
"name": "NonExportedInterface",
"properties": Array [
PropertyDeclaration {
"end": 55,
"isOptional": false,
"isStatic": false,
"name": "property1",
"start": 37,
"type": "string",
"visibility": 2,
},
PropertyDeclaration {
"end": 78,
"isOptional": false,
"isStatic": false,
"name": "property2",
"start": 60,
"type": "number",
"visibility": 2,
},
],
"start": 0,
}
`;
exports[`TypescriptParser Declaration parsing Interfaces should parse an exported interface 1`] = `
InterfaceDeclaration {
"accessors": Array [],
"end": 286,
"isExported": true,
"methods": Array [
MethodDeclaration {
"end": 247,
"isAbstract": true,
"isAsync": false,
"isOptional": false,
"isStatic": false,
"name": "method1",
"parameters": Array [
ObjectBoundParameterDeclaration {
"end": 245,
"endCharacter": "}",
"parameters": Array [
ParameterDeclaration {
"end": 235,
"name": "param1",
"start": 229,
"type": undefined,
},
ParameterDeclaration {
"end": 243,
"name": "param2",
"start": 237,
"type": undefined,
},
],
"start": 227,
"startCharacter": "{",
},
],
"start": 219,
"type": undefined,
"variables": Array [],
"visibility": 2,
},
MethodDeclaration {
"end": 284,
"isAbstract": true,
"isAsync": false,
"isOptional": false,
"isStatic": false,
"name": "method2",
"parameters": Array [
ArrayBoundParameterDeclaration {
"end": 276,
"endCharacter": "]",
"parameters": Array [
ParameterDeclaration {
"end": 267,
"name": "param1",
"start": 261,
"type": undefined,
},
ParameterDeclaration {
"end": 275,
"name": "param2",
"start": 269,
"type": undefined,
},
],
"start": 260,
"startCharacter": "[",
},
],
"start": 252,
"type": "void",
"variables": Array [],
"visibility": 2,
},
],
"name": "ExportedInterface",
"properties": Array [
PropertyDeclaration {
"end": 191,
"isOptional": false,
"isStatic": false,
"name": "property1",
"start": 173,
"type": "string",
"visibility": 2,
},
PropertyDeclaration {
"end": 214,
"isOptional": false,
"isStatic": false,
"name": "property2",
"start": 196,
"type": "number",
"visibility": 2,
},
],
"start": 132,
}
`;
exports[`TypescriptParser Declaration parsing Interfaces should parse optional functions 1`] = `
InterfaceDeclaration {
"accessors": Array [],
"end": 714,
"isExported": false,
"methods": Array [
MethodDeclaration {
"end": 680,
"isAbstract": true,
"isAsync": false,
"isOptional": false,
"isStatic": false,
"name": "nonOptionalFunction2",
"parameters": Array [],
"start": 651,
"type": "void",
"variables": Array [],
"visibility": 2,
},
MethodDeclaration {
"end": 712,
"isAbstract": true,
"isAsync": false,
"isOptional": true,
"isStatic": false,
"name": "optionalFunction3",
"parameters": Array [],
"start": 685,
"type": "void",
"variables": Array [],
"visibility": 2,
},
],
"name": "OptionalFunctionInterface",
"properties": Array [
PropertyDeclaration {
"end": 572,
"isOptional": false,
"isStatic": false,
"name": "nonOptionalFunction1",
"start": 539,
"type": "() => void",
"visibility": 2,
},
PropertyDeclaration {
"end": 610,
"isOptional": true,
"isStatic": false,
"name": "optionalFunction1",
"start": 577,
"type": "{ (): void }",
"visibility": 2,
},
PropertyDeclaration {
"end": 646,
"isOptional": true,
"isStatic": false,
"name": "optionalFunction2",
"start": 615,
"type": "() => void",
"visibility": 2,
},
],
"start": 497,
}
`;
exports[`TypescriptParser Declaration parsing Interfaces should parse optional properties 1`] = `
Array [
PropertyDeclaration {
"end": 422,
"isOptional": false,
"isStatic": false,
"name": "nonOptional",
"start": 402,
"type": "string",
"visibility": 2,
},
PropertyDeclaration {
"end": 470,
"isOptional": false,
"isStatic": false,
"name": "alsoNonOptional",
"start": 427,
"type": "string | null | undefined",
"visibility": 2,
},
PropertyDeclaration {
"end": 493,
"isOptional": true,
"isStatic": false,
"name": "optional",
"start": 475,
"type": "string",
"visibility": 2,
},
]
`;
exports[`TypescriptParser Declaration parsing Modules should parse a module 1`] = `
Module {
"declarations": Array [
FunctionDeclaration {
"end": 62,
"isAsync": false,
"isExported": true,
"name": "modFunc",
"parameters": Array [],
"start": 30,
"type": "void",
"variables": Array [],
},
],
"end": 64,
"exports": Array [],
"imports": Array [],
"name": "Module",
"resources": Array [],
"start": 0,
"usages": Array [],
}
`;
exports[`TypescriptParser Declaration parsing Modules should parse a namespace 1`] = `
Namespace {
"declarations": Array [
ClassDeclaration {
"accessors": Array [],
"end": 121,
"isExported": false,
"methods": Array [],
"name": "NotExported",
"properties": Array [],
"start": 100,
},
EnumDeclaration {
"end": 188,
"isExported": true,
"members": Array [
"MemberA",
"MemberB",
],
"name": "E
gitextract_bof42bjs/ ├── .appveyor.yml ├── .gitignore ├── .npmignore ├── .npmrc ├── .travis.yml ├── LICENSE ├── README.md ├── config/ │ ├── tsconfig.base.json │ └── tsconfig.build.json ├── jest.json ├── package.json ├── src/ │ ├── DeclarationIndex.ts │ ├── Node.ts │ ├── SymbolSpecifier.ts │ ├── TypescriptParser.ts │ ├── clonable/ │ │ └── Clonable.ts │ ├── code-generators/ │ │ ├── TypescriptCodeGenerator.ts │ │ ├── TypescriptGenerationOptions.ts │ │ └── typescript-generators/ │ │ ├── accessorDeclaration.ts │ │ ├── externalModuleImport.ts │ │ ├── methodDeclaration.ts │ │ ├── namedImport.ts │ │ ├── namespaceImport.ts │ │ ├── parameterDeclaration.ts │ │ ├── propertyDeclaration.ts │ │ ├── stringImport.ts │ │ ├── symbolSpecifier.ts │ │ └── variableDeclaration.ts │ ├── declarations/ │ │ ├── AccessorDeclaration.ts │ │ ├── ClassDeclaration.ts │ │ ├── ConstructorDeclaration.ts │ │ ├── Declaration.ts │ │ ├── DeclarationInfo.ts │ │ ├── DeclarationVisibility.ts │ │ ├── DefaultDeclaration.ts │ │ ├── EnumDeclaration.ts │ │ ├── FunctionDeclaration.ts │ │ ├── InterfaceDeclaration.ts │ │ ├── MethodDeclaration.ts │ │ ├── ModuleDeclaration.ts │ │ ├── ParameterDeclaration.ts │ │ ├── PropertyDeclaration.ts │ │ ├── TypeAliasDeclaration.ts │ │ ├── VariableDeclaration.ts │ │ └── index.ts │ ├── errors/ │ │ └── NotGeneratableYetError.ts │ ├── exports/ │ │ ├── AllExport.ts │ │ ├── AssignedExport.ts │ │ ├── Export.ts │ │ ├── NamedExport.ts │ │ └── index.ts │ ├── imports/ │ │ ├── ExternalModuleImport.ts │ │ ├── Import.ts │ │ ├── NamedImport.ts │ │ ├── NamespaceImport.ts │ │ ├── StringImport.ts │ │ └── index.ts │ ├── index.ts │ ├── node-parser/ │ │ ├── class-parser.ts │ │ ├── enum-parser.ts │ │ ├── export-parser.ts │ │ ├── function-parser.ts │ │ ├── identifier-parser.ts │ │ ├── import-parser.ts │ │ ├── index.ts │ │ ├── interface-parser.ts │ │ ├── module-parser.ts │ │ ├── parse-utilities.ts │ │ ├── traverse-ast.ts │ │ ├── type-alias-parser.ts │ │ └── variable-parser.ts │ ├── resources/ │ │ ├── File.ts │ │ ├── Module.ts │ │ ├── Namespace.ts │ │ ├── Resource.ts │ │ └── index.ts │ ├── type-guards/ │ │ ├── TypescriptGuards.ts │ │ └── TypescriptHeroGuards.ts │ └── utilities/ │ ├── PathHelpers.ts │ └── StringTemplate.ts ├── test/ │ ├── SpecificUsageCases.spec.ts │ ├── TypescriptParser.spec.ts │ ├── __snapshots__/ │ │ ├── SpecificUsageCases.spec.ts.snap │ │ └── TypescriptParser.spec.ts.snap │ ├── _workspace/ │ │ ├── .gitignore │ │ ├── declaration-index/ │ │ │ ├── _index.ts │ │ │ ├── another-classes.ts │ │ │ ├── circular-export/ │ │ │ │ ├── circularExport1.ts │ │ │ │ └── circularExport2.ts │ │ │ ├── classes.ts │ │ │ ├── exports/ │ │ │ │ ├── classes.ts │ │ │ │ ├── export-alias.ts │ │ │ │ ├── export-all.ts │ │ │ │ ├── export-from-export.ts │ │ │ │ └── export-some.ts │ │ │ ├── helper-functions.ts │ │ │ ├── index.ts │ │ │ ├── myReactTemplate.tsx │ │ │ ├── prototype-funcs.ts │ │ │ ├── reactFile.tsx │ │ │ └── specific-cases/ │ │ │ └── reindex-with-global-module-export/ │ │ │ └── classes.ts │ │ ├── specific-usage-cases/ │ │ │ ├── i18next-destructure/ │ │ │ │ ├── destructure-my-component.tsx │ │ │ │ └── import-my-component.tsx │ │ │ └── reexport/ │ │ │ ├── reexport-default.ts │ │ │ └── reexport-import.ts │ │ └── typescript-parser/ │ │ ├── async.ts │ │ ├── class.ts │ │ ├── enum.ts │ │ ├── exportsOnly.ts │ │ ├── function.ts │ │ ├── importsOnly.ts │ │ ├── interface.ts │ │ ├── javascript.js │ │ ├── jsx.jsx │ │ ├── module.ts │ │ ├── parameters.ts │ │ ├── specific-cases/ │ │ │ ├── 1.tsx │ │ │ ├── 2.tsx │ │ │ └── 3.tsx │ │ ├── typeAlias.ts │ │ ├── usagesOnly.ts │ │ ├── usagesOnly.tsx │ │ ├── variable.ts │ │ └── webpack-bundle.js │ ├── code-generators/ │ │ ├── TypescriptCodeGenerator.spec.ts │ │ └── __snapshots__/ │ │ └── TypescriptCodeGenerator.spec.ts.snap │ ├── declaration-index/ │ │ ├── DeclarationIndex.spec.ts │ │ ├── __snapshots__/ │ │ │ └── DeclarationIndex.spec.ts.snap │ │ └── specific-cases/ │ │ └── reindex-with-global-module/ │ │ ├── DeclarationIndex.reindex-with-global-module-export.spec.ts │ │ └── __snapshots__/ │ │ └── DeclarationIndex.reindex-with-global-module-export.spec.ts.snap │ ├── imports/ │ │ └── Imports.spec.ts │ ├── parsing/ │ │ ├── Flags.spec.ts │ │ └── __snapshots__/ │ │ └── Flags.spec.ts.snap │ ├── testUtilities.ts │ └── utilities/ │ └── PathHelpers.spec.ts ├── tsconfig.json └── tslint.json
SYMBOL INDEX (1287 symbols across 89 files)
FILE: src/DeclarationIndex.ts
function getNodeLibraryName (line 24) | function getNodeLibraryName(path: string): string {
type Resources (line 35) | type Resources = { [name: string]: Resource };
type IndexDelta (line 42) | type IndexDelta = {
type FileChanges (line 54) | interface FileChanges {
class DeclarationIndex (line 67) | class DeclarationIndex {
method indexReady (line 96) | public get indexReady(): boolean {
method index (line 107) | public get index(): { [declaration: string]: DeclarationInfo[] } | und...
method declarationInfos (line 119) | public get declarationInfos(): DeclarationInfo[] {
method constructor (line 126) | constructor(private parser: TypescriptParser, private rootPath: string...
method calculateIndexDelta (line 138) | public static calculateIndexDelta(
method reset (line 176) | public reset(): void {
method buildIndex (line 190) | public async buildIndex(filePathes: string[]): Promise<void> {
method reindexForChanges (line 217) | public async reindexForChanges(changes: FileChanges): Promise<IndexDel...
method getExportedResources (line 279) | private getExportedResources(resourceToCheck: string): string[] {
method doesExportResource (line 303) | private doesExportResource(resource: File, resourcePath: string): bool...
method parseResources (line 329) | private async parseResources(files: File[] = []): Promise<Resources> {
method createIndex (line 366) | private async createIndex(resources: Resources): Promise<{ [declaratio...
method processResourceExports (line 409) | private processResourceExports(
method processAllFromExport (line 470) | private processAllFromExport(exportingLib: Resource, exportedLib: Reso...
method processNamedFromExport (line 486) | private processNamedFromExport(
method processAssignedExport (line 518) | private processAssignedExport(
FILE: src/Node.ts
type Node (line 8) | interface Node {
FILE: src/SymbolSpecifier.ts
class SymbolSpecifier (line 11) | class SymbolSpecifier implements Clonable<SymbolSpecifier> {
method constructor (line 12) | constructor(public specifier: string, public alias?: string) { }
method clone (line 21) | public clone(): SymbolSpecifier {
FILE: src/TypescriptParser.ts
class TypescriptParser (line 47) | class TypescriptParser {
method parseSource (line 58) | public async parseSource(source: string, scriptKind: ScriptKind = Scri...
method parseFile (line 78) | public async parseFile(filePath: string, rootPath: string): Promise<Fi...
method parseFiles (line 92) | public async parseFiles(
method parseTypescript (line 135) | private parseTypescript(source: SourceFile, rootPath: string): File {
method parse (line 155) | private parse(resource: Resource, root: Node): void {
FILE: src/clonable/Clonable.ts
type Clonable (line 8) | interface Clonable<T> {
FILE: src/code-generators/TypescriptCodeGenerator.ts
type Generatable (line 31) | type Generatable = Declaration | Import | Export | SymbolSpecifier;
type Generators (line 36) | type Generators = { [name: string]: (generatable: Generatable, options: ...
constant GENERATORS (line 41) | const GENERATORS: Generators = {
class TypescriptCodeGenerator (line 61) | class TypescriptCodeGenerator {
method constructor (line 62) | constructor(private options: TypescriptGenerationOptions) { }
method generate (line 72) | public generate(declaration: Generatable): string {
FILE: src/code-generators/TypescriptGenerationOptions.ts
type MultiLineImportRule (line 1) | enum MultiLineImportRule {
type TypescriptGenerationOptions (line 13) | interface TypescriptGenerationOptions {
FILE: src/code-generators/typescript-generators/accessorDeclaration.ts
function generateAccessorDeclaration (line 13) | function generateAccessorDeclaration(
FILE: src/code-generators/typescript-generators/externalModuleImport.ts
function generateExternalModuleImport (line 12) | function generateExternalModuleImport(
FILE: src/code-generators/typescript-generators/methodDeclaration.ts
function generateMethodDeclaration (line 14) | function generateMethodDeclaration(method: MethodDeclaration, { tabSize ...
FILE: src/code-generators/typescript-generators/namedImport.ts
function specifierSort (line 23) | function specifierSort(i1: SymbolSpecifier, i2: SymbolSpecifier): number {
function generateNamedImport (line 44) | function generateNamedImport(
function getImportSpecifiers (line 108) | function getImportSpecifiers(namedImport: NamedImport, spaceBraces: bool...
FILE: src/code-generators/typescript-generators/namespaceImport.ts
function generateNamespaceImport (line 12) | function generateNamespaceImport(
FILE: src/code-generators/typescript-generators/parameterDeclaration.ts
function generateParameterDeclaration (line 10) | function generateParameterDeclaration(parameter: ParameterDeclaration): ...
FILE: src/code-generators/typescript-generators/propertyDeclaration.ts
function generatePropertyDeclaration (line 13) | function generatePropertyDeclaration(
FILE: src/code-generators/typescript-generators/stringImport.ts
function generateStringImport (line 12) | function generateStringImport(imp: StringImport, { stringQuoteStyle, eol...
FILE: src/code-generators/typescript-generators/symbolSpecifier.ts
function generateSymbolSpecifier (line 10) | function generateSymbolSpecifier(specifier: SymbolSpecifier): string {
FILE: src/code-generators/typescript-generators/variableDeclaration.ts
function generateVariableDelcaration (line 10) | function generateVariableDelcaration(variable: VariableDeclaration): str...
FILE: src/declarations/AccessorDeclaration.ts
method constructor (line 19) | constructor(
class GetterDeclaration (line 37) | class GetterDeclaration extends AccessorDeclaration { }
class SetterDeclaration (line 46) | class SetterDeclaration extends AccessorDeclaration { }
FILE: src/declarations/ClassDeclaration.ts
class ClassDeclaration (line 16) | class ClassDeclaration implements ClassLikeDeclaration, ExportableDeclar...
method constructor (line 23) | constructor(
FILE: src/declarations/ConstructorDeclaration.ts
class ConstructorDeclaration (line 12) | class ConstructorDeclaration implements CallableDeclaration {
method constructor (line 16) | constructor(
FILE: src/declarations/Declaration.ts
type Declaration (line 16) | interface Declaration extends Node {
type TypedDeclaration (line 34) | interface TypedDeclaration extends Declaration {
type GenericDeclaration (line 54) | interface GenericDeclaration extends Declaration {
type ExportableDeclaration (line 74) | interface ExportableDeclaration extends Declaration {
type ScopedDeclaration (line 91) | interface ScopedDeclaration extends Declaration {
type ClassLikeDeclaration (line 110) | interface ClassLikeDeclaration extends Declaration {
type CallableDeclaration (line 144) | interface CallableDeclaration extends Declaration {
type AbstractDeclaration (line 169) | interface AbstractDeclaration extends Declaration {
type OptionalDeclaration (line 186) | interface OptionalDeclaration extends Declaration {
type StaticDeclaration (line 203) | interface StaticDeclaration extends Declaration {
type AsyncDeclaration (line 220) | interface AsyncDeclaration extends Declaration {
FILE: src/declarations/DeclarationInfo.ts
class DeclarationInfo (line 10) | class DeclarationInfo {
method constructor (line 11) | constructor(public declaration: Declaration, public from: string) { }
FILE: src/declarations/DeclarationVisibility.ts
function getVisibilityText (line 7) | function getVisibilityText(visibility?: DeclarationVisibility): string {
type DeclarationVisibility (line 26) | const enum DeclarationVisibility {
FILE: src/declarations/DefaultDeclaration.ts
class DefaultDeclaration (line 13) | class DefaultDeclaration implements ExportableDeclaration {
method exportedDeclaration (line 18) | public get exportedDeclaration(): Declaration {
method constructor (line 26) | constructor(
FILE: src/declarations/EnumDeclaration.ts
class EnumDeclaration (line 10) | class EnumDeclaration implements ExportableDeclaration {
method constructor (line 13) | constructor(
FILE: src/declarations/FunctionDeclaration.ts
class FunctionDeclaration (line 14) | class FunctionDeclaration implements AsyncDeclaration, CallableDeclarati...
method constructor (line 18) | constructor(
FILE: src/declarations/InterfaceDeclaration.ts
class InterfaceDeclaration (line 14) | class InterfaceDeclaration implements ClassLikeDeclaration, ExportableDe...
method constructor (line 20) | constructor(
FILE: src/declarations/MethodDeclaration.ts
class MethodDeclaration (line 24) | class MethodDeclaration implements
method constructor (line 36) | constructor(
FILE: src/declarations/ModuleDeclaration.ts
class ModuleDeclaration (line 11) | class ModuleDeclaration implements Declaration {
method constructor (line 12) | constructor(
FILE: src/declarations/ParameterDeclaration.ts
class ParameterDeclaration (line 11) | class ParameterDeclaration implements TypedDeclaration {
method constructor (line 12) | constructor(public name: string, public type: string | undefined, publ...
class BoundParameterDeclaration (line 15) | class BoundParameterDeclaration extends ParameterDeclaration {
method name (line 19) | public get name(): string {
method name (line 25) | public set name(_: string) { }
method type (line 27) | public get type(): string {
method type (line 34) | public set type(_: string) { }
method constructor (line 36) | constructor(private startCharacter: string, private endCharacter: stri...
class ObjectBoundParameterDeclaration (line 41) | class ObjectBoundParameterDeclaration extends BoundParameterDeclaration {
method constructor (line 42) | constructor(start?: number, end?: number) {
class ArrayBoundParameterDeclaration (line 47) | class ArrayBoundParameterDeclaration extends BoundParameterDeclaration {
method constructor (line 48) | constructor(start?: number, end?: number) {
FILE: src/declarations/PropertyDeclaration.ts
class PropertyDeclaration (line 12) | class PropertyDeclaration implements OptionalDeclaration, ScopedDeclarat...
method constructor (line 13) | constructor(
FILE: src/declarations/TypeAliasDeclaration.ts
class TypeAliasDeclaration (line 11) | class TypeAliasDeclaration implements ExportableDeclaration {
method constructor (line 12) | constructor(
FILE: src/declarations/VariableDeclaration.ts
class VariableDeclaration (line 11) | class VariableDeclaration implements ExportableDeclaration, TypedDeclara...
method constructor (line 12) | constructor(
FILE: src/errors/NotGeneratableYetError.ts
class NotGeneratableYetError (line 10) | class NotGeneratableYetError extends Error {
method constructor (line 11) | constructor(generatable: Generatable) {
FILE: src/exports/AllExport.ts
class AllExport (line 10) | class AllExport implements Export {
method constructor (line 11) | constructor(public start: number, public end: number, public from: str...
FILE: src/exports/AssignedExport.ts
class AssignedExport (line 15) | class AssignedExport implements Export {
method exported (line 24) | public get exported(): (ExportableDeclaration | Resource)[] {
method constructor (line 35) | constructor(
FILE: src/exports/Export.ts
type Export (line 10) | interface Export extends Node { }
FILE: src/exports/NamedExport.ts
class NamedExport (line 11) | class NamedExport implements Export {
method constructor (line 14) | constructor(public start: number, public end: number, public from: str...
FILE: src/imports/ExternalModuleImport.ts
class ExternalModuleImport (line 11) | class ExternalModuleImport implements AliasedImport {
method isNew (line 12) | public get isNew(): boolean {
method constructor (line 16) | constructor(public libraryName: string, public alias: string, public s...
method clone (line 25) | public clone(): ExternalModuleImport {
FILE: src/imports/Import.ts
type Import (line 11) | interface Import extends Clonable<Import>, Node {
type AliasedImport (line 38) | interface AliasedImport extends Import {
FILE: src/imports/NamedImport.ts
class NamedImport (line 14) | class NamedImport implements Import {
method isNew (line 18) | public get isNew(): boolean {
method constructor (line 22) | constructor(public libraryName: string, public start?: number, public ...
method clone (line 31) | public clone(): NamedImport {
FILE: src/imports/NamespaceImport.ts
class NamespaceImport (line 10) | class NamespaceImport implements AliasedImport {
method isNew (line 11) | public get isNew(): boolean {
method constructor (line 15) | constructor(public libraryName: string, public alias: string, public s...
method clone (line 24) | public clone(): NamespaceImport {
FILE: src/imports/StringImport.ts
class StringImport (line 10) | class StringImport implements Import {
method isNew (line 11) | public get isNew(): boolean {
method constructor (line 15) | constructor(public libraryName: string, public start?: number, public ...
method clone (line 24) | public clone(): StringImport {
FILE: src/node-parser/class-parser.ts
function parseClassIdentifiers (line 47) | function parseClassIdentifiers(tsResource: Resource, node: Node): void {
function parseCtorParams (line 69) | function parseCtorParams(
function parseClass (line 120) | function parseClass(tsResource: Resource, node: ClassDeclaration): void {
FILE: src/node-parser/enum-parser.ts
function parseEnum (line 14) | function parseEnum(resource: Resource, node: EnumDeclaration): void {
FILE: src/node-parser/export-parser.ts
function parseExport (line 19) | function parseExport(resource: Resource, node: ExportDeclaration | Expor...
FILE: src/node-parser/function-parser.ts
function parseFunctionParts (line 51) | function parseFunctionParts(
function parseMethodParams (line 78) | function parseMethodParams(
function parseFunction (line 143) | function parseFunction(resource: Resource, node: FunctionDeclaration): v...
FILE: src/node-parser/identifier-parser.ts
function allowedIfLastIdentifier (line 43) | function allowedIfLastIdentifier(node: Node): boolean {
function allowedIfPropertyAccessFirst (line 63) | function allowedIfPropertyAccessFirst(node: Node): boolean {
function parseIdentifier (line 83) | function parseIdentifier(resource: Resource, node: Identifier): void {
FILE: src/node-parser/import-parser.ts
function parseImport (line 32) | function parseImport(resource: Resource, node: ImportDeclaration | Impor...
FILE: src/node-parser/interface-parser.ts
function parseInterface (line 27) | function parseInterface(resource: Resource, node: InterfaceDeclaration):...
FILE: src/node-parser/module-parser.ts
function parseModule (line 16) | function parseModule(resource: Resource, node: ModuleDeclaration): Resou...
FILE: src/node-parser/parse-utilities.ts
function isNodeExported (line 15) | function isNodeExported(node: Node): boolean {
function isNodeDefaultExported (line 28) | function isNodeDefaultExported(node: Node): boolean {
function getNodeType (line 40) | function getNodeType(node: TypeNode | undefined): string | undefined {
function containsModifier (line 52) | function containsModifier(node: Node, modifierKind: SyntaxKind): boolean {
function getNodeVisibility (line 64) | function getNodeVisibility(node: Node): DeclarationVisibility | undefined {
function getDefaultResourceIdentifier (line 91) | function getDefaultResourceIdentifier(resource: Resource): string {
FILE: src/node-parser/traverse-ast.ts
function traverseAst (line 1) | function traverseAst(root: Node, visit: (node: Node) => void, skipConten...
FILE: src/node-parser/type-alias-parser.ts
function parseTypeAlias (line 14) | function parseTypeAlias(resource: Resource, node: TypeAliasDeclaration):...
FILE: src/node-parser/variable-parser.ts
function parseVariable (line 16) | function parseVariable(parent: Resource | CallableDeclaration, node: Var...
FILE: src/resources/File.ts
class File (line 20) | class File implements Resource, Node {
method identifier (line 27) | public get identifier(): string {
method nonLocalUsages (line 31) | public get nonLocalUsages(): string[] {
method parsedPath (line 49) | public get parsedPath(): ParsedPath {
method isWorkspaceFile (line 60) | public get isWorkspaceFile(): boolean {
method constructor (line 64) | constructor(public filePath: string, private rootPath: string, public ...
FILE: src/resources/Module.ts
class Module (line 16) | class Module implements Resource, Node {
method identifier (line 23) | public get identifier(): string {
method nonLocalUsages (line 27) | public get nonLocalUsages(): string[] {
method constructor (line 37) | constructor(public name: string, public start: number, public end: num...
method getNamespaceAlias (line 47) | public getNamespaceAlias(): string {
FILE: src/resources/Namespace.ts
class Namespace (line 16) | class Namespace implements Resource, Node {
method identifier (line 23) | public get identifier(): string {
method nonLocalUsages (line 27) | public get nonLocalUsages(): string[] {
method constructor (line 37) | constructor(public name: string, public start: number, public end: num...
method getNamespaceAlias (line 47) | public getNamespaceAlias(): string {
FILE: src/resources/Resource.ts
type Resource (line 12) | interface Resource {
FILE: src/type-guards/TypescriptGuards.ts
function isImportDeclaration (line 32) | function isImportDeclaration(node?: Node): node is ImportDeclaration {
function isImportEqualsDeclaration (line 43) | function isImportEqualsDeclaration(node?: Node): node is ImportEqualsDec...
function isNamespaceImport (line 54) | function isNamespaceImport(node?: Node): node is NamespaceImport {
function isNamedImports (line 65) | function isNamedImports(node?: Node): node is NamedImports {
function isNamedExports (line 76) | function isNamedExports(node?: Node): node is NamedExports {
function isStringLiteral (line 87) | function isStringLiteral(node?: Node): node is StringLiteral {
function isIdentifier (line 98) | function isIdentifier(node?: Node): node is Identifier {
function isExternalModuleReference (line 109) | function isExternalModuleReference(node?: Node): node is ExternalModuleR...
function isExportDeclaration (line 120) | function isExportDeclaration(node?: Node): node is ExportDeclaration {
function isObjectBindingPattern (line 131) | function isObjectBindingPattern(node?: Node): node is ObjectBindingPatte...
function isArrayBindingPattern (line 142) | function isArrayBindingPattern(node?: Node): node is ArrayBindingPattern {
function isFunctionDeclaration (line 153) | function isFunctionDeclaration(node?: Node): node is FunctionDeclaration {
function isMethodSignature (line 164) | function isMethodSignature(node?: Node): node is MethodSignature {
function isPropertySignature (line 175) | function isPropertySignature(node?: Node): node is PropertySignature {
function isMethodDeclaration (line 186) | function isMethodDeclaration(node?: Node): node is MethodDeclaration {
function isPropertyDeclaration (line 197) | function isPropertyDeclaration(node?: Node): node is PropertyDeclaration {
function isConstructorDeclaration (line 208) | function isConstructorDeclaration(node?: Node): node is ConstructorDecla...
function isGetAccessorDeclaration (line 219) | function isGetAccessorDeclaration(node?: Node): node is GetAccessorDecla...
function isSetAccessorDeclaration (line 230) | function isSetAccessorDeclaration(node?: Node): node is SetAccessorDecla...
FILE: src/type-guards/TypescriptHeroGuards.ts
function isCallableDeclaration (line 11) | function isCallableDeclaration(obj: any): obj is CallableDeclaration {
function isExportableDeclaration (line 22) | function isExportableDeclaration(obj: any): obj is ExportableDeclaration {
function isAliasedImport (line 33) | function isAliasedImport(obj: any): obj is AliasedImport {
FILE: src/utilities/PathHelpers.ts
function normalizePathUri (line 10) | function normalizePathUri(uri: string): string {
function normalizeFilename (line 27) | function normalizeFilename(filepath: string): string {
function toPosix (line 35) | function toPosix(path: string): string {
FILE: src/utilities/StringTemplate.ts
function stringTemplate (line 9) | function stringTemplate(strings: TemplateStringsArray, ...keys: number[]...
FILE: test/_workspace/declaration-index/another-classes.ts
class Class1 (line 1) | class Class1 { }
FILE: test/_workspace/declaration-index/circular-export/circularExport1.ts
class ExportedCircularClass1 (line 1) | class ExportedCircularClass1 {
FILE: test/_workspace/declaration-index/circular-export/circularExport2.ts
class ExportedCircularClass2 (line 1) | class ExportedCircularClass2 {
FILE: test/_workspace/declaration-index/classes.ts
class MyClass (line 1) | class MyClass {
method doSomething (line 2) | public doSomething(): void { }
class FancierLibraryClass (line 5) | class FancierLibraryClass {
method doSomethingAwesome (line 6) | public doSomethingAwesome(): void { }
class Class1 (line 9) | class Class1 { }
class Class2 (line 10) | class Class2 { }
class Class3 (line 11) | class Class3 { }
class Class4 (line 12) | class Class4 { }
class Class5 (line 13) | class Class5 { }
class Class6 (line 14) | class Class6 { }
class Class7 (line 15) | class Class7 { }
class Class8 (line 16) | class Class8 { }
class Class9 (line 17) | class Class9 { }
FILE: test/_workspace/declaration-index/exports/classes.ts
class Class1 (line 1) | class Class1 { }
class Class2 (line 2) | class Class2 { }
class Class3 (line 3) | class Class3 { }
class Class4 (line 4) | class Class4 { }
class Class5 (line 5) | class Class5 { }
class Class6 (line 6) | class Class6 { }
class Class7 (line 7) | class Class7 { }
class Class8 (line 8) | class Class8 { }
class Class9 (line 9) | class Class9 { }
FILE: test/_workspace/declaration-index/helper-functions.ts
function isString (line 1) | function isString(str: any): str is string {
function isNumber (line 5) | function isNumber(str: any): str is number {
FILE: test/_workspace/declaration-index/prototype-funcs.ts
function toString (line 1) | function toString(): string {
function hasOwnProperty (line 5) | function hasOwnProperty(): boolean {
FILE: test/_workspace/declaration-index/reactFile.tsx
function foobar (line 3) | function foobar() {
FILE: test/_workspace/declaration-index/specific-cases/reindex-with-global-module-export/classes.ts
class MyClass (line 2) | class MyClass {
method doSomething (line 3) | public doSomething(): void { }
FILE: test/_workspace/typescript-parser/async.ts
class Class1 (line 1) | class Class1 {
method staticAsync (line 2) | public static async staticAsync() { }
method func (line 3) | public func(): void { }
method asyncFunc (line 4) | public async asyncFunc(): Promise<void> { }
method asyncFuncWithoutType (line 5) | public async asyncFuncWithoutType() { }
function func (line 8) | function func(): void { }
function asyncFunc (line 9) | async function asyncFunc(): Promise<void> { }
function asyncFuncWithoutType (line 10) | async function asyncFuncWithoutType() { }
function promiseFunc (line 11) | function promiseFunc(): Promise<void> { }
FILE: test/_workspace/typescript-parser/class.ts
method method1 (line 2) | public method1() { }
class NonExportedClass (line 7) | class NonExportedClass {
method constructor (line 8) | constructor(public param1: string) { }
method method1 (line 10) | public method1(): void { }
method method2 (line 11) | protected method2(): void { }
method method3 (line 12) | private method3(): void {
class ExportedClass (line 17) | class ExportedClass {
method property (line 22) | public get property(): string {
method property (line 26) | public set property(value: string) {
class Generic (line 31) | class Generic<T> { }
class MultiGeneric (line 32) | class MultiGeneric<TIn, TOut, TError> { }
class PropertyAccessors (line 34) | class PropertyAccessors {
method getOnly (line 35) | public get getOnly(): string {
method setOnly (line 39) | public set setOnly(value: any) {
method getAndSet (line 42) | public get getAndSet(): string {
method getAndSet (line 46) | public set getAndSet(value: string) {
class ObjAndArrDestruct (line 58) | class ObjAndArrDestruct {
method constructor (line 59) | constructor({ p1, p2 }: any, [p3, p4]: any) { }
method objMethod (line 61) | public objMethod({ p1, p2, p3 }: any): void { }
method arrMethod (line 63) | public arrMethod([p1, p2, p3]: string[]): void { }
method objAndArrMethod (line 65) | public objAndArrMethod([p1, p2, p3]: string[], { p4, p5 }: any): void { }
class OptionalProperties (line 68) | class OptionalProperties {
class StaticThings (line 74) | class StaticThings {
method method (line 76) | public static method(): void { }
method methodNonStatic (line 77) | public methodNonStatic(): void { }
FILE: test/_workspace/typescript-parser/enum.ts
type Enumeration (line 1) | enum Enumeration {
type ConstantEnumeration (line 7) | const enum ConstantEnumeration {
FILE: test/_workspace/typescript-parser/function.ts
function function1 (line 1) | function function1(param1): string {
function function2 (line 6) | function function2(param1: string, { objParam1, objParam2 }, [arrParam1,...
function withoutReturnType (line 10) | function withoutReturnType() {
function typeGuard (line 14) | function typeGuard(str: any): str is number {
FILE: test/_workspace/typescript-parser/interface.ts
type NonExportedInterface (line 1) | interface NonExportedInterface {
type ExportedInterface (line 8) | interface ExportedInterface {
type Generic (line 15) | interface Generic<T> { }
type MultiGeneric (line 16) | interface MultiGeneric<TIn, TOut, TError> { }
type OptionalPropertyInterface (line 18) | interface OptionalPropertyInterface {
type OptionalFunctionInterface (line 24) | interface OptionalFunctionInterface {
FILE: test/_workspace/typescript-parser/javascript.js
class ES6Class (line 3) | class ES6Class {
method constructor (line 4) | constructor() { }
method doSomething (line 6) | doSomething() { }
FILE: test/_workspace/typescript-parser/jsx.jsx
class ES6Class (line 4) | class ES6Class {
method render (line 5) | render() {
FILE: test/_workspace/typescript-parser/module.ts
class NotExported (line 6) | class NotExported { }
type Exported (line 8) | enum Exported {
FILE: test/_workspace/typescript-parser/parameters.ts
function normal (line 1) | function normal(p1: string): void { }
function arrBound1 (line 3) | function arrBound1([p1, p2]): void { }
function arrBound2 (line 5) | function arrBound2([p1, p2]: [string, Type]): void { }
function arrBound3 (line 7) | function arrBound3([p1, p2]: [string]): void { }
function arrBound4 (line 9) | function arrBound4([p1, p2]: [string, number, boolean]): void { }
function objBound1 (line 11) | function objBound1({ p1, p2 }): void { }
function objBound2 (line 13) | function objBound2({ p1, p2 }: Type): void { }
function objBound3 (line 15) | function objBound3({ p1, p2 }: { p1: string, p2: Type }): void { }
function objBound4 (line 17) | function objBound4({ p1, p2 }: { p1: string }): void { }
function objBound5 (line 19) | function objBound5({ p1, p2 }: { p1: string, p2: number, p3: boolean }):...
function mixed (line 21) | function mixed(p1: string, { p2, p3 }: { p2: string, p3: number }, [p4, ...
FILE: test/_workspace/typescript-parser/specific-cases/1.tsx
type Props (line 51) | interface Props {
type State (line 67) | interface State {
function mapStateToProps (line 78) | function mapStateToProps(state: AppState, ownProps: Props): Partial<Prop...
function mapDispatchToProps (line 91) | function mapDispatchToProps(dispatch: Dispatch<AppState>, ownProps: Prop...
function multiplier (line 130) | function multiplier(playerCount: number): (monsterCount: number) => numb...
class EncounterPlanner (line 182) | class EncounterPlanner extends React.Component<Props, State> {
method constructor (line 194) | constructor(props: Props) {
method componentWillMount (line 199) | public componentWillMount(): void {
method componentWillReceiveProps (line 208) | public componentWillReceiveProps(next: Props): void {
method render (line 219) | public render(): JSX.Element {
method xpSumThreshold (line 551) | private xpSumThreshold(difficulty: 'easy' | 'medium' | 'hard' | 'deadl...
method adjustedXp (line 566) | private adjustedXp(xp: number): number {
method handleMonsterSelected (line 572) | private handleMonsterSelected(monster: Monster): void {
method saveNewEncounter (line 584) | private saveNewEncounter(name: string): void {
method handleSaveEncounter (line 597) | private handleSaveEncounter(): void {
FILE: test/_workspace/typescript-parser/specific-cases/2.tsx
class EncounterPlanner (line 1) | class EncounterPlanner extends React.Component<Props, State> {
method constructor (line 13) | constructor(props: Props) {
method componentWillMount (line 18) | public componentWillMount(): void {
method componentWillReceiveProps (line 27) | public componentWillReceiveProps(next: Props): void {
method render (line 38) | public render(): JSX.Element {
method xpSumThreshold (line 370) | private xpSumThreshold(difficulty: 'easy' | 'medium' | 'hard' | 'deadl...
method adjustedXp (line 385) | private adjustedXp(xp: number): number {
method handleMonsterSelected (line 391) | private handleMonsterSelected(monster: Monster): void {
method saveNewEncounter (line 403) | private saveNewEncounter(name: string): void {
method handleSaveEncounter (line 416) | private handleSaveEncounter(): void {
FILE: test/_workspace/typescript-parser/specific-cases/3.tsx
class CharacterOverview (line 1) | class CharacterOverview extends React.Component<Props, State>{
method render (line 2) | public render(): JSX.Element {
method handleRowClick (line 102) | private handleRowClick(chars: PlayerCharacter[], idx: number): void {
FILE: test/_workspace/typescript-parser/typeAlias.ts
type Alias (line 1) | type Alias = {};
type ExportedAlias (line 3) | type ExportedAlias = {};
FILE: test/_workspace/typescript-parser/usagesOnly.ts
class Class (line 1) | @ClassDecorator
method func (line 11) | public func( @ParamDecorator() param: TypedParam, defaultParam = Defau...
method prv (line 14) | private prv(param): ReturnValue {
class Class (line 35) | class Class extends DefaultClass {
method func (line 11) | public func( @ParamDecorator() param: TypedParam, defaultParam = Defau...
method prv (line 14) | private prv(param): ReturnValue {
class Class (line 39) | class Class extends GenericClass<GenericType> {
method func (line 11) | public func( @ParamDecorator() param: TypedParam, defaultParam = Defau...
method prv (line 14) | private prv(param): ReturnValue {
FILE: test/_workspace/typescript-parser/usagesOnly.tsx
function foobar (line 1) | function foobar() {
FILE: test/_workspace/typescript-parser/webpack-bundle.js
function t (line 1) | function t(n){if(r[n])return r[n].exports;var a=r[n]={i:n,l:!1,exports:{...
function n (line 1) | function n(){s.onerror=s.onload=null,clearTimeout(u);var t=a[e];0!==t&&(...
function t (line 1) | function t(){return gr.apply(null,arguments)}
function r (line 1) | function r(e){return e instanceof Array||"[object Array]"===Object.proto...
function a (line 1) | function a(e){return null!=e&&"[object Object]"===Object.prototype.toStr...
function i (line 1) | function i(e){var t;for(t in e)return!1;return!0}
function o (line 1) | function o(e){return void 0===e}
function s (line 1) | function s(e){return"number"==typeof e||"[object Number]"===Object.proto...
function u (line 1) | function u(e){return e instanceof Date||"[object Date]"===Object.prototy...
function d (line 1) | function d(e,t){var n,r=[];for(n=0;n<e.length;++n)r.push(t(e[n],n));retu...
function c (line 1) | function c(e,t){return Object.prototype.hasOwnProperty.call(e,t)}
function l (line 1) | function l(e,t){for(var n in t)c(t,n)&&(e[n]=t[n]);return c(t,"toString"...
function _ (line 1) | function _(e,t,n,r){return Mt(e,t,n,r,!0).utc()}
function f (line 1) | function f(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,...
function m (line 1) | function m(e){return null==e._pf&&(e._pf=f()),e._pf}
function h (line 1) | function h(e){if(null==e._isValid){var t=m(e),n=Yr.call(t.parsedDatePart...
function p (line 1) | function p(e){var t=_(NaN);return null!=e?l(m(t),e):m(t).userInvalidated...
function y (line 1) | function y(e,t){var n,r,a;if(o(t._isAMomentObject)||(e._isAMomentObject=...
function v (line 1) | function v(e){y(this,e),this._d=new Date(null!=e._d?e._d.getTime():NaN),...
function M (line 1) | function M(e){return e instanceof v||null!=e&&null!=e._isAMomentObject}
function g (line 1) | function g(e){return e<0?Math.ceil(e)||0:Math.floor(e)}
function L (line 1) | function L(e){var t=+e,n=0;return 0!==t&&isFinite(t)&&(n=g(t)),n}
function Y (line 1) | function Y(e,t,n){var r,a=Math.min(e.length,t.length),i=Math.abs(e.lengt...
function k (line 1) | function k(e){!1===t.suppressDeprecationWarnings&&"undefined"!=typeof co...
function b (line 1) | function b(e,n){var r=!0;return l(function(){if(null!=t.deprecationHandl...
function w (line 1) | function w(e,n){null!=t.deprecationHandler&&t.deprecationHandler(e,n),wr...
function D (line 1) | function D(e){return e instanceof Function||"[object Function]"===Object...
function T (line 1) | function T(e){var t,n;for(n in e)t=e[n],D(t)?this[n]=t:this["_"+n]=t;thi...
function S (line 1) | function S(e,t){var n,r=l({},e);for(n in t)c(t,n)&&(a(e[n])&&a(t[n])?(r[...
function j (line 1) | function j(e){null!=e&&this.set(e)}
function x (line 1) | function x(e,t,n){var r=this._calendar[e]||this._calendar.sameElse;retur...
function H (line 1) | function H(e){var t=this._longDateFormat[e],n=this._longDateFormat[e.toU...
function O (line 1) | function O(){return this._invalidDate}
function A (line 1) | function A(e){return this._ordinal.replace("%d",e)}
function E (line 1) | function E(e,t,n,r){var a=this._relativeTime[n];return D(a)?a(e,t,n,r):a...
function P (line 1) | function P(e,t){var n=this._relativeTime[e>0?"future":"past"];return D(n...
function $ (line 1) | function $(e,t){var n=e.toLowerCase();Ar[n]=Ar[n+"s"]=Ar[t]=e}
function C (line 1) | function C(e){return"string"==typeof e?Ar[e]||Ar[e.toLowerCase()]:void 0}
function F (line 1) | function F(e){var t,n,r={};for(n in e)c(e,n)&&(t=C(n))&&(r[t]=e[n]);retu...
function W (line 1) | function W(e,t){Er[e]=t}
function I (line 1) | function I(e){var t=[];for(var n in e)t.push({unit:n,priority:Er[n]});re...
function R (line 1) | function R(e,n){return function(r){return null!=r?(z(this,e,r),t.updateO...
function N (line 1) | function N(e,t){return e.isValid()?e._d["get"+(e._isUTC?"UTC":"")+t]():NaN}
function z (line 1) | function z(e,t,n){e.isValid()&&e._d["set"+(e._isUTC?"UTC":"")+t](n)}
function J (line 1) | function J(e){return e=C(e),D(this[e])?this[e]():this}
function U (line 1) | function U(e,t){if("object"==typeof e){e=F(e);for(var n=I(e),r=0;r<n.len...
function V (line 1) | function V(e,t,n){var r=""+Math.abs(e),a=t-r.length;return(e>=0?n?"+":""...
function G (line 1) | function G(e,t,n,r){var a=r;"string"==typeof r&&(a=function(){return thi...
function q (line 1) | function q(e){return e.match(/\[[\s\S]/)?e.replace(/^\[|\]$/g,""):e.repl...
function B (line 1) | function B(e){var t,n,r=e.match(Pr);for(t=0,n=r.length;t<n;t++)Fr[r[t]]?...
function K (line 1) | function K(e,t){return e.isValid()?(t=Z(t,e.localeData()),Cr[t]=Cr[t]||B...
function Z (line 1) | function Z(e,t){function n(e){return t.longDateFormat(e)||e}var r=5;for(...
function Q (line 1) | function Q(e,t,n){na[e]=D(t)?t:function(e,r){return e&&n?n:t}}
function X (line 1) | function X(e,t){return c(na,e)?na[e](t._strict,t._locale):new RegExp(ee(...
function ee (line 1) | function ee(e){return te(e.replace("\\","").replace(/\\(\[)|\\(\])|\[([^...
function te (line 1) | function te(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}
function ne (line 1) | function ne(e,t){var n,r=t;for("string"==typeof e&&(e=[e]),s(t)&&(r=func...
function re (line 1) | function re(e,t){ne(e,function(e,n,r,a){r._w=r._w||{},t(e,r._w,r,a)})}
function ae (line 1) | function ae(e,t,n){null!=t&&c(ra,e)&&ra[e](t,n._a,n,e)}
function ie (line 1) | function ie(e,t){return new Date(Date.UTC(e,t+1,0)).getUTCDate()}
function oe (line 1) | function oe(e,t){return e?r(this._months)?this._months[e.month()]:this._...
function se (line 1) | function se(e,t){return e?r(this._monthsShort)?this._monthsShort[e.month...
function ue (line 1) | function ue(e,t,n){var r,a,i,o=e.toLocaleLowerCase();if(!this._monthsPar...
function de (line 1) | function de(e,t,n){var r,a,i;if(this._monthsParseExact)return ue.call(th...
function ce (line 1) | function ce(e,t){var n;if(!e.isValid())return e;if("string"==typeof t)if...
function le (line 1) | function le(e){return null!=e?(ce(this,e),t.updateOffset(this,!0),this):...
function _e (line 1) | function _e(){return ie(this.year(),this.month())}
function fe (line 1) | function fe(e){return this._monthsParseExact?(c(this,"_monthsRegex")||he...
function me (line 1) | function me(e){return this._monthsParseExact?(c(this,"_monthsRegex")||he...
function he (line 1) | function he(){function e(e,t){return t.length-e.length}var t,n,r=[],a=[]...
function pe (line 1) | function pe(e){return ye(e)?366:365}
function ye (line 1) | function ye(e){return e%4==0&&e%100!=0||e%400==0}
function ve (line 1) | function ve(){return ye(this.year())}
function Me (line 1) | function Me(e,t,n,r,a,i,o){var s=new Date(e,t,n,r,a,i,o);return e<100&&e...
function ge (line 1) | function ge(e){var t=new Date(Date.UTC.apply(null,arguments));return e<1...
function Le (line 1) | function Le(e,t,n){var r=7+t-n;return-(7+ge(e,0,r).getUTCDay()-t)%7+r-1}
function Ye (line 1) | function Ye(e,t,n,r,a){var i,o,s=(7+n-r)%7,u=Le(e,r,a),d=1+7*(t-1)+s+u;r...
function ke (line 1) | function ke(e,t,n){var r,a,i=Le(e.year(),t,n),o=Math.floor((e.dayOfYear(...
function be (line 1) | function be(e,t,n){var r=Le(e,t,n),a=Le(e+1,t,n);return(pe(e)-r+a)/7}
function we (line 1) | function we(e){return ke(e,this._week.dow,this._week.doy).week}
function De (line 1) | function De(){return this._week.dow}
function Te (line 1) | function Te(){return this._week.doy}
function Se (line 1) | function Se(e){var t=this.localeData().week(this);return null==e?t:this....
function je (line 1) | function je(e){var t=ke(this,1,4).week;return null==e?t:this.add(7*(e-t)...
function xe (line 1) | function xe(e,t){return"string"!=typeof e?e:isNaN(e)?(e=t.weekdaysParse(...
function He (line 1) | function He(e,t){return"string"==typeof e?t.weekdaysParse(e)%7||7:isNaN(...
function Oe (line 1) | function Oe(e,t){return e?r(this._weekdays)?this._weekdays[e.day()]:this...
function Ae (line 1) | function Ae(e){return e?this._weekdaysShort[e.day()]:this._weekdaysShort}
function Ee (line 1) | function Ee(e){return e?this._weekdaysMin[e.day()]:this._weekdaysMin}
function Pe (line 1) | function Pe(e,t,n){var r,a,i,o=e.toLocaleLowerCase();if(!this._weekdaysP...
function $e (line 1) | function $e(e,t,n){var r,a,i;if(this._weekdaysParseExact)return Pe.call(...
function Ce (line 1) | function Ce(e){if(!this.isValid())return null!=e?this:NaN;var t=this._is...
function Fe (line 1) | function Fe(e){if(!this.isValid())return null!=e?this:NaN;var t=(this.da...
function We (line 1) | function We(e){if(!this.isValid())return null!=e?this:NaN;if(null!=e){va...
function Ie (line 1) | function Ie(e){return this._weekdaysParseExact?(c(this,"_weekdaysRegex")...
function Re (line 1) | function Re(e){return this._weekdaysParseExact?(c(this,"_weekdaysRegex")...
function Ne (line 1) | function Ne(e){return this._weekdaysParseExact?(c(this,"_weekdaysRegex")...
function ze (line 1) | function ze(){function e(e,t){return t.length-e.length}var t,n,r,a,i,o=[...
function Je (line 1) | function Je(){return this.hours()%12||12}
function Ue (line 1) | function Ue(){return this.hours()||24}
function Ve (line 1) | function Ve(e,t){G(e,0,0,function(){return this.localeData().meridiem(th...
function Ge (line 1) | function Ge(e,t){return t._meridiemParse}
function qe (line 1) | function qe(e){return"p"===(e+"").toLowerCase().charAt(0)}
function Be (line 1) | function Be(e,t,n){return e>11?n?"pm":"PM":n?"am":"AM"}
function Ke (line 1) | function Ke(e){return e?e.toLowerCase().replace("_","-"):e}
function Ze (line 1) | function Ze(e){for(var t,n,r,a,i=0;i<e.length;){for(a=Ke(e[i]).split("-"...
function Qe (line 1) | function Qe(t){var r=null;if(!Ha[t]&&void 0!==e&&e&&e.exports)try{r=Ta._...
function Xe (line 1) | function Xe(e,t){var n;return e&&(n=o(t)?nt(e):et(e,t))&&(Ta=n),Ta._abbr}
function et (line 1) | function et(e,t){if(null!==t){var n=xa;if(t.abbr=e,null!=Ha[e])w("define...
function tt (line 1) | function tt(e,t){if(null!=t){var n,r=xa;null!=Ha[e]&&(r=Ha[e]._config),t...
function nt (line 1) | function nt(e){var t;if(e&&e._locale&&e._locale._abbr&&(e=e._locale._abb...
function rt (line 1) | function rt(){return Sr(Ha)}
function at (line 1) | function at(e){var t,n=e._a;return n&&-2===m(e).overflow&&(t=n[ia]<0||n[...
function it (line 1) | function it(e){var t,n,r,a,i,o,s=e._i,u=Aa.exec(s)||Ea.exec(s);if(u){for...
function ot (line 1) | function ot(e){var t,n,r,a,i,o,s,u,d={" GMT":" +0000"," EDT":" -0400"," ...
function st (line 1) | function st(e){var n=Fa.exec(e._i);if(null!==n)return void(e._d=new Date...
function ut (line 1) | function ut(e,t,n){return null!=e?e:null!=t?t:n}
function dt (line 1) | function dt(e){var n=new Date(t.now());return e._useUTC?[n.getUTCFullYea...
function ct (line 1) | function ct(e){var t,n,r,a,i=[];if(!e._d){for(r=dt(e),e._w&&null==e._a[o...
function lt (line 1) | function lt(e){var t,n,r,a,i,o,s,u;if(t=e._w,null!=t.GG||null!=t.W||null...
function _t (line 1) | function _t(e){if(e._f===t.ISO_8601)return void it(e);if(e._f===t.RFC_28...
function ft (line 1) | function ft(e,t,n){var r;return null==n?t:null!=e.meridiemHour?e.meridie...
function mt (line 1) | function mt(e){var t,n,r,a,i;if(0===e._f.length)return m(e).invalidForma...
function ht (line 1) | function ht(e){if(!e._d){var t=F(e._i);e._a=d([t.year,t.month,t.day||t.d...
function pt (line 1) | function pt(e){var t=new v(at(yt(e)));return t._nextDay&&(t.add(1,"d"),t...
function yt (line 1) | function yt(e){var t=e._i,n=e._f;return e._locale=e._locale||nt(e._l),nu...
function vt (line 1) | function vt(e){var n=e._i;o(n)?e._d=new Date(t.now()):u(n)?e._d=new Date...
function Mt (line 1) | function Mt(e,t,n,o,s){var u={};return!0!==n&&!1!==n||(o=n,n=void 0),(a(...
function gt (line 1) | function gt(e,t,n,r){return Mt(e,t,n,r,!1)}
function Lt (line 1) | function Lt(e,t){var n,a;if(1===t.length&&r(t[0])&&(t=t[0]),!t.length)re...
function Yt (line 1) | function Yt(){return Lt("isBefore",[].slice.call(arguments,0))}
function kt (line 1) | function kt(){return Lt("isAfter",[].slice.call(arguments,0))}
function bt (line 1) | function bt(e){for(var t in e)if(-1===za.indexOf(t)||null!=e[t]&&isNaN(e...
function wt (line 1) | function wt(){return this._isValid}
function Dt (line 1) | function Dt(){return Ut(NaN)}
function Tt (line 1) | function Tt(e){var t=F(e),n=t.year||0,r=t.quarter||0,a=t.month||0,i=t.we...
function St (line 1) | function St(e){return e instanceof Tt}
function jt (line 1) | function jt(e){return e<0?-1*Math.round(-1*e):Math.round(e)}
function xt (line 1) | function xt(e,t){G(e,0,0,function(){var e=this.utcOffset(),n="+";return ...
function Ht (line 1) | function Ht(e,t){var n=(t||"").match(e);if(null===n)return null;var r=n[...
function Ot (line 1) | function Ot(e,n){var r,a;return n._isUTC?(r=n.clone(),a=(M(e)||u(e)?e.va...
function At (line 1) | function At(e){return 15*-Math.round(e._d.getTimezoneOffset()/15)}
function Et (line 1) | function Et(e,n,r){var a,i=this._offset||0;if(!this.isValid())return nul...
function Pt (line 1) | function Pt(e,t){return null!=e?("string"!=typeof e&&(e=-e),this.utcOffs...
function $t (line 1) | function $t(e){return this.utcOffset(0,e)}
function Ct (line 1) | function Ct(e){return this._isUTC&&(this.utcOffset(0,e),this._isUTC=!1,e...
function Ft (line 1) | function Ft(){if(null!=this._tzm)this.utcOffset(this._tzm,!1,!0);else if...
function Wt (line 1) | function Wt(e){return!!this.isValid()&&(e=e?gt(e).utcOffset():0,(this.ut...
function It (line 1) | function It(){return this.utcOffset()>this.clone().month(0).utcOffset()|...
function Rt (line 1) | function Rt(){if(!o(this._isDSTShifted))return this._isDSTShifted;var e=...
function Nt (line 1) | function Nt(){return!!this.isValid()&&!this._isUTC}
function zt (line 1) | function zt(){return!!this.isValid()&&this._isUTC}
function Jt (line 1) | function Jt(){return!!this.isValid()&&(this._isUTC&&0===this._offset)}
function Ut (line 1) | function Ut(e,t){var n,r,a,i=e,o=null;return St(e)?i={ms:e._milliseconds...
function Vt (line 1) | function Vt(e,t){var n=e&&parseFloat(e.replace(",","."));return(isNaN(n)...
function Gt (line 1) | function Gt(e,t){var n={milliseconds:0,months:0};return n.months=t.month...
function qt (line 1) | function qt(e,t){var n;return e.isValid()&&t.isValid()?(t=Ot(t,e),e.isBe...
function Bt (line 1) | function Bt(e,t){return function(n,r){var a,i;return null===r||isNaN(+r)...
function Kt (line 1) | function Kt(e,n,r,a){var i=n._milliseconds,o=jt(n._days),s=jt(n._months)...
function Zt (line 1) | function Zt(e,t){var n=e.diff(t,"days",!0);return n<-6?"sameElse":n<-1?"...
function Qt (line 1) | function Qt(e,n){var r=e||gt(),a=Ot(r,this).startOf("day"),i=t.calendarF...
function Xt (line 1) | function Xt(){return new v(this)}
function en (line 1) | function en(e,t){var n=M(e)?e:gt(e);return!(!this.isValid()||!n.isValid(...
function tn (line 1) | function tn(e,t){var n=M(e)?e:gt(e);return!(!this.isValid()||!n.isValid(...
function nn (line 1) | function nn(e,t,n,r){return r=r||"()",("("===r[0]?this.isAfter(e,n):!thi...
function rn (line 1) | function rn(e,t){var n,r=M(e)?e:gt(e);return!(!this.isValid()||!r.isVali...
function an (line 1) | function an(e,t){return this.isSame(e,t)||this.isAfter(e,t)}
function on (line 1) | function on(e,t){return this.isSame(e,t)||this.isBefore(e,t)}
function sn (line 1) | function sn(e,t,n){var r,a,i,o;return this.isValid()?(r=Ot(e,this),r.isV...
function un (line 1) | function un(e,t){var n,r,a=12*(t.year()-e.year())+(t.month()-e.month()),...
function dn (line 1) | function dn(){return this.clone().locale("en").format("ddd MMM DD YYYY H...
function cn (line 1) | function cn(){if(!this.isValid())return null;var e=this.clone().utc();re...
function ln (line 1) | function ln(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */...
function _n (line 1) | function _n(e){e||(e=this.isUtc()?t.defaultFormatUtc:t.defaultFormat);va...
function fn (line 1) | function fn(e,t){return this.isValid()&&(M(e)&&e.isValid()||gt(e).isVali...
function mn (line 1) | function mn(e){return this.from(gt(),e)}
function hn (line 1) | function hn(e,t){return this.isValid()&&(M(e)&&e.isValid()||gt(e).isVali...
function pn (line 1) | function pn(e){return this.to(gt(),e)}
function yn (line 1) | function yn(e){var t;return void 0===e?this._locale._abbr:(t=nt(e),null!...
function vn (line 1) | function vn(){return this._locale}
function Mn (line 1) | function Mn(e){switch(e=C(e)){case"year":this.month(0);case"quarter":cas...
function gn (line 1) | function gn(e){return void 0===(e=C(e))||"millisecond"===e?this:("date"=...
function Ln (line 1) | function Ln(){return this._d.valueOf()-6e4*(this._offset||0)}
function Yn (line 1) | function Yn(){return Math.floor(this.valueOf()/1e3)}
function kn (line 1) | function kn(){return new Date(this.valueOf())}
function bn (line 1) | function bn(){var e=this;return[e.year(),e.month(),e.date(),e.hour(),e.m...
function wn (line 1) | function wn(){var e=this;return{years:e.year(),months:e.month(),date:e.d...
function Dn (line 1) | function Dn(){return this.isValid()?this.toISOString():null}
function Tn (line 1) | function Tn(){return h(this)}
function Sn (line 1) | function Sn(){return l({},m(this))}
function jn (line 1) | function jn(){return m(this).overflow}
function xn (line 1) | function xn(){return{input:this._i,format:this._f,locale:this._locale,is...
function Hn (line 1) | function Hn(e,t){G(0,[e,e.length],0,t)}
function On (line 1) | function On(e){return $n.call(this,e,this.week(),this.weekday(),this.loc...
function An (line 1) | function An(e){return $n.call(this,e,this.isoWeek(),this.isoWeekday(),1,4)}
function En (line 1) | function En(){return be(this.year(),1,4)}
function Pn (line 1) | function Pn(){var e=this.localeData()._week;return be(this.year(),e.dow,...
function $n (line 1) | function $n(e,t,n,r,a){var i;return null==e?ke(this,r,a).year:(i=be(e,r,...
function Cn (line 1) | function Cn(e,t,n,r,a){var i=Ye(e,t,n,r,a),o=ge(i.year,0,i.dayOfYear);re...
function Fn (line 1) | function Fn(e){return null==e?Math.ceil((this.month()+1)/3):this.month(3...
function Wn (line 1) | function Wn(e){var t=Math.round((this.clone().startOf("day")-this.clone(...
function In (line 1) | function In(e,t){t[ca]=L(1e3*("0."+e))}
function Rn (line 1) | function Rn(){return this._isUTC?"UTC":""}
function Nn (line 1) | function Nn(){return this._isUTC?"Coordinated Universal Time":""}
function zn (line 1) | function zn(e){return gt(1e3*e)}
function Jn (line 1) | function Jn(){return gt.apply(null,arguments).parseZone()}
function Un (line 1) | function Un(e){return e}
function Vn (line 1) | function Vn(e,t,n,r){var a=nt(),i=_().set(r,t);return a[n](i,e)}
function Gn (line 1) | function Gn(e,t,n){if(s(e)&&(t=e,e=void 0),e=e||"",null!=t)return Vn(e,t...
function qn (line 1) | function qn(e,t,n,r){"boolean"==typeof e?(s(t)&&(n=t,t=void 0),t=t||""):...
function Bn (line 1) | function Bn(e,t){return Gn(e,t,"months")}
function Kn (line 1) | function Kn(e,t){return Gn(e,t,"monthsShort")}
function Zn (line 1) | function Zn(e,t,n){return qn(e,t,n,"weekdays")}
function Qn (line 1) | function Qn(e,t,n){return qn(e,t,n,"weekdaysShort")}
function Xn (line 1) | function Xn(e,t,n){return qn(e,t,n,"weekdaysMin")}
function er (line 1) | function er(){var e=this._data;return this._milliseconds=ri(this._millis...
function tr (line 1) | function tr(e,t,n,r){var a=Ut(t,n);return e._milliseconds+=r*a._millisec...
function nr (line 1) | function nr(e,t){return tr(this,e,t,1)}
function rr (line 1) | function rr(e,t){return tr(this,e,t,-1)}
function ar (line 1) | function ar(e){return e<0?Math.floor(e):Math.ceil(e)}
function ir (line 1) | function ir(){var e,t,n,r,a,i=this._milliseconds,o=this._days,s=this._mo...
function or (line 1) | function or(e){return 4800*e/146097}
function sr (line 1) | function sr(e){return 146097*e/4800}
function ur (line 1) | function ur(e){if(!this.isValid())return NaN;var t,n,r=this._millisecond...
function dr (line 1) | function dr(){return this.isValid()?this._milliseconds+864e5*this._days+...
function cr (line 1) | function cr(e){return function(){return this.as(e)}}
function lr (line 1) | function lr(e){return e=C(e),this.isValid()?this[e+"s"]():NaN}
function _r (line 1) | function _r(e){return function(){return this.isValid()?this._data[e]:NaN}}
function fr (line 1) | function fr(){return g(this.days()/7)}
function mr (line 1) | function mr(e,t,n,r,a){return a.relativeTime(t||1,!!n,e,r)}
function hr (line 1) | function hr(e,t,n){var r=Ut(e).abs(),a=Mi(r.as("s")),i=Mi(r.as("m")),o=M...
function pr (line 1) | function pr(e){return void 0===e?Mi:"function"==typeof e&&(Mi=e,!0)}
function yr (line 1) | function yr(e,t){return void 0!==gi[e]&&(void 0===t?gi[e]:(gi[e]=t,"s"==...
function vr (line 1) | function vr(e){if(!this.isValid())return this.localeData().invalidDate()...
function Mr (line 1) | function Mr(){if(!this.isValid())return this.localeData().invalidDate();...
function e (line 6) | function e(e){return void 0===e||null===e}
function n (line 6) | function n(e){return void 0!==e&&null!==e}
function r (line 6) | function r(e){return!0===e}
function a (line 6) | function a(e){return!1===e}
function i (line 6) | function i(e){return"string"==typeof e||"number"==typeof e||"boolean"==t...
function o (line 6) | function o(e){return null!==e&&"object"==typeof e}
function s (line 6) | function s(e){return"[object Object]"===fa.call(e)}
function u (line 6) | function u(e){return"[object RegExp]"===fa.call(e)}
function d (line 6) | function d(e){var t=parseFloat(e);return t>=0&&Math.floor(t)===t&&isFini...
function c (line 6) | function c(e){return null==e?"":"object"==typeof e?JSON.stringify(e,null...
function l (line 6) | function l(e){var t=parseFloat(e);return isNaN(t)?e:t}
function _ (line 6) | function _(e,t){for(var n=Object.create(null),r=e.split(","),a=0;a<r.len...
function f (line 6) | function f(e,t){if(e.length){var n=e.indexOf(t);if(n>-1)return e.splice(...
function m (line 6) | function m(e,t){return pa.call(e,t)}
function h (line 6) | function h(e){var t=Object.create(null);return function(n){return t[n]||...
function p (line 6) | function p(e,t){function n(n){var r=arguments.length;return r?r>1?e.appl...
function y (line 6) | function y(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n...
function v (line 6) | function v(e,t){for(var n in t)e[n]=t[n];return e}
function M (line 6) | function M(e){for(var t={},n=0;n<e.length;n++)e[n]&&v(t,e[n]);return t}
function g (line 6) | function g(e,t,n){}
function L (line 6) | function L(e,t){if(e===t)return!0;var n=o(e),r=o(t);if(!n||!r)return!n&&...
function Y (line 6) | function Y(e,t){for(var n=0;n<e.length;n++)if(L(e[n],t))return n;return-1}
function k (line 6) | function k(e){var t=!1;return function(){t||(t=!0,e.apply(this,arguments...
function b (line 6) | function b(e){var t=(e+"").charCodeAt(0);return 36===t||95===t}
function w (line 6) | function w(e,t,n,r){Object.defineProperty(e,t,{value:n,enumerable:!!r,wr...
function D (line 6) | function D(e){if(!ja.test(e)){var t=e.split(".");return function(e){for(...
function T (line 6) | function T(e,t,n){if(Ta.errorHandler)Ta.errorHandler.call(null,e,t,n);el...
function S (line 6) | function S(e){return"function"==typeof e&&/native code/.test(e.toString())}
function j (line 6) | function j(e){Ka.target&&Za.push(Ka.target),Ka.target=e}
function x (line 6) | function x(){Ka.target=Za.pop()}
function H (line 6) | function H(e,t,n){e.__proto__=t}
function O (line 6) | function O(e,t,n){for(var r=0,a=n.length;r<a;r++){var i=n[r];w(e,i,t[i])}}
function A (line 6) | function A(e,t){if(o(e)){var n;return m(e,"__ob__")&&e.__ob__ instanceof...
function E (line 6) | function E(e,t,n,r,a){var i=new Ka,o=Object.getOwnPropertyDescriptor(e,t...
function P (line 6) | function P(e,t,n){if(Array.isArray(e)&&d(t))return e.length=Math.max(e.l...
function $ (line 6) | function $(e,t){if(Array.isArray(e)&&d(t))e.splice(t,1);else{var n=e.__o...
function C (line 6) | function C(e){for(var t=void 0,n=0,r=e.length;n<r;n++)(t=e[n])&&t.__ob__...
function F (line 6) | function F(e,t){if(!t)return e;for(var n,r,a,i=Object.keys(t),o=0;o<i.le...
function W (line 6) | function W(e,t,n){return n?e||t?function(){var r="function"==typeof t?t....
function I (line 6) | function I(e,t){return t?e?e.concat(t):Array.isArray(t)?t:[t]:e}
function R (line 6) | function R(e,t){var n=Object.create(e||null);return t?v(n,t):n}
function N (line 6) | function N(e){var t=e.props;if(t){var n,r,a={};if(Array.isArray(t))for(n...
function z (line 6) | function z(e){var t=e.inject;if(Array.isArray(t))for(var n=e.inject={},r...
function J (line 6) | function J(e){var t=e.directives;if(t)for(var n in t){var r=t[n];"functi...
function U (line 6) | function U(e,t,n){function r(r){var a=ri[r]||ai;u[r]=a(e[r],t[r],n,r)}"f...
function V (line 6) | function V(e,t,n,r){if("string"==typeof n){var a=e[t];if(m(a,n))return a...
function G (line 6) | function G(e,t,n,r){var a=t[e],i=!m(n,e),o=n[e];if(K(Boolean,a.type)&&(i...
function q (line 6) | function q(e,t,n){if(m(t,"default")){var r=t.default;return e&&e.$option...
function B (line 6) | function B(e){var t=e&&e.toString().match(/^\s*function (\w+)/);return t...
function K (line 6) | function K(e,t){if(!Array.isArray(t))return B(t)===B(e);for(var n=0,r=t....
function Z (line 6) | function Z(e){return new ii(void 0,void 0,void 0,String(e))}
function Q (line 6) | function Q(e){var t=new ii(e.tag,e.data,e.children,e.text,e.elm,e.contex...
function X (line 6) | function X(e){for(var t=e.length,n=new Array(t),r=0;r<t;r++)n[r]=Q(e[r])...
function ee (line 6) | function ee(e){function t(){var e=arguments,n=t.fns;if(!Array.isArray(n)...
function te (line 6) | function te(t,n,r,a,i){var o,s,u,d;for(o in t)s=t[o],u=n[o],d=di(o),e(s)...
function ne (line 6) | function ne(t,a,i){function o(){i.apply(this,arguments),f(s.fns,o)}var s...
function re (line 6) | function re(t,r,a){var i=r.options.props;if(!e(i)){var o={},s=t.attrs,u=...
function ae (line 6) | function ae(e,t,r,a,i){if(n(t)){if(m(t,r))return e[r]=t[r],i||delete t[r...
function ie (line 6) | function ie(e){for(var t=0;t<e.length;t++)if(Array.isArray(e[t]))return ...
function oe (line 6) | function oe(e){return i(e)?[Z(e)]:Array.isArray(e)?ue(e):void 0}
function se (line 6) | function se(e){return n(e)&&n(e.text)&&a(e.isComment)}
function ue (line 6) | function ue(t,a){var o,s,u,d=[];for(o=0;o<t.length;o++)e(s=t[o])||"boole...
function de (line 6) | function de(e,t){return e.__esModule&&e.default&&(e=e.default),o(e)?t.ex...
function ce (line 6) | function ce(e,t,n,r,a){var i=ui();return i.asyncFactory=e,i.asyncMeta={d...
function le (line 6) | function le(t,a,i){if(r(t.error)&&n(t.errorComp))return t.errorComp;if(n...
function _e (line 6) | function _e(e){if(Array.isArray(e))for(var t=0;t<e.length;t++){var r=e[t...
function fe (line 6) | function fe(e){e._events=Object.create(null),e._hasHookEvent=!1;var t=e....
function me (line 6) | function me(e,t,n){n?si.$once(e,t):si.$on(e,t)}
function he (line 6) | function he(e,t){si.$off(e,t)}
function pe (line 6) | function pe(e,t,n){si=e,te(t,n||{},me,he,e)}
function ye (line 6) | function ye(e,t){var n={};if(!e)return n;for(var r=[],a=0,i=e.length;a<i...
function ve (line 6) | function ve(e){return e.isComment||" "===e.text}
function Me (line 6) | function Me(e,t){t=t||{};for(var n=0;n<e.length;n++)Array.isArray(e[n])?...
function ge (line 6) | function ge(e){var t=e.$options,n=t.parent;if(n&&!t.abstract){for(;n.$op...
function Le (line 6) | function Le(e,t,n){e.$el=t,e.$options.render||(e.$options.render=ui),De(...
function Ye (line 6) | function Ye(e,t,n,r,a){var i=!!(a||e.$options._renderChildren||r.data.sc...
function ke (line 6) | function ke(e){for(;e&&(e=e.$parent);)if(e._inactive)return!0;return!1}
function be (line 6) | function be(e,t){if(t){if(e._directInactive=!1,ke(e))return}else if(e._d...
function we (line 6) | function we(e,t){if(!(t&&(e._directInactive=!0,ke(e))||e._inactive)){e._...
function De (line 6) | function De(e,t){var n=e.$options[t];if(n)for(var r=0,a=n.length;r<a;r++...
function Te (line 6) | function Te(){pi=li.length=_i.length=0,fi={},mi=hi=!1}
function Se (line 6) | function Se(){hi=!0;var e,t;for(li.sort(function(e,t){return e.id-t.id})...
function je (line 6) | function je(e){for(var t=e.length;t--;){var n=e[t],r=n.vm;r._watcher===n...
function xe (line 6) | function xe(e){e._inactive=!1,_i.push(e)}
function He (line 6) | function He(e){for(var t=0;t<e.length;t++)e[t]._inactive=!0,be(e[t],!0)}
function Oe (line 6) | function Oe(e){var t=e.id;if(null==fi[t]){if(fi[t]=!0,hi){for(var n=li.l...
function Ae (line 6) | function Ae(e){Mi.clear(),Ee(e,Mi)}
function Ee (line 6) | function Ee(e,t){var n,r,a=Array.isArray(e);if((a||o(e))&&Object.isExten...
function Pe (line 6) | function Pe(e,t,n){gi.get=function(){return this[t][n]},gi.set=function(...
function $e (line 6) | function $e(e){e._watchers=[];var t=e.$options;t.props&&Ce(e,t.props),t....
function Ce (line 6) | function Ce(e,t){var n=e.$options.propsData||{},r=e._props={},a=e.$optio...
function Fe (line 6) | function Fe(e){var t=e.$options.data;s(t=e._data="function"==typeof t?We...
function We (line 6) | function We(e,t){try{return e.call(t)}catch(e){return T(e,t,"data()"),{}}}
function Ie (line 6) | function Ie(e,t){var n=e._computedWatchers=Object.create(null);for(var r...
function Re (line 6) | function Re(e,t,n){"function"==typeof n?(gi.get=Ne(t),gi.set=g):(gi.get=...
function Ne (line 6) | function Ne(e){return function(){var t=this._computedWatchers&&this._com...
function ze (line 6) | function ze(e,t){e.$options.props;for(var n in t)e[n]=null==t[n]?g:p(t[n...
function Je (line 6) | function Je(e,t){for(var n in t){var r=t[n];if(Array.isArray(r))for(var ...
function Ue (line 6) | function Ue(e,t,n,r){return s(n)&&(r=n,n=n.handler),"string"==typeof n&&...
function Ve (line 6) | function Ve(e){var t=e.$options.provide;t&&(e._provided="function"==type...
function Ge (line 6) | function Ge(e){var t=qe(e.$options.inject,e);t&&(ti.shouldConvert=!1,Obj...
function qe (line 6) | function qe(e,t){if(e){for(var n=Object.create(null),r=Ga?Reflect.ownKey...
function Be (line 6) | function Be(e,t,r,a,i){var o={},s=e.options.props;if(n(s))for(var u in s...
function Ke (line 6) | function Ke(e,t){for(var n in t)e[va(n)]=t[n]}
function Ze (line 6) | function Ze(t,a,i,s,u){if(!e(t)){var d=i.$options._base;if(o(t)&&(t=d.ex...
function Qe (line 6) | function Qe(e,t,r,a){var i=e.componentOptions,o={_isComponent:!0,parent:...
function Xe (line 6) | function Xe(e){e.hook||(e.hook={});for(var t=0;t<ki.length;t++){var n=ki...
function et (line 6) | function et(e,t){return function(n,r,a,i){e(n,r,a,i),t(n,r,a,i)}}
function tt (line 6) | function tt(e,t){var r=e.model&&e.model.prop||"value",a=e.model&&e.model...
function nt (line 6) | function nt(e,t,n,a,o,s){return(Array.isArray(n)||i(n))&&(o=a,a=n,n=void...
function rt (line 6) | function rt(e,t,r,a,i){if(n(r)&&n(r.__ob__))return ui();if(n(r)&&n(r.is)...
function at (line 6) | function at(t,r){if(t.ns=r,"foreignObject"!==t.tag&&n(t.children))for(va...
function it (line 6) | function it(e,t){var r,a,i,s,u;if(Array.isArray(e)||"string"==typeof e)f...
function ot (line 6) | function ot(e,t,n,r){var a=this.$scopedSlots[e];return a?(n=n||{},r&&(n=...
function st (line 6) | function st(e){return V(this.$options,"filters",e,!0)||ka}
function ut (line 6) | function ut(e,t,n){var r=Ta.keyCodes[t]||n;return Array.isArray(r)?-1===...
function dt (line 6) | function dt(e,t,n,r,a){if(n&&o(n)){Array.isArray(n)&&(n=M(n));var i;for(...
function ct (line 6) | function ct(e,t){var n=this._staticTrees[e];return n&&!t?Array.isArray(n...
function lt (line 6) | function lt(e,t,n){return _t(e,"__once__"+t+(n?"_"+n:""),!0),e}
function _t (line 6) | function _t(e,t,n){if(Array.isArray(e))for(var r=0;r<e.length;r++)e[r]&&...
function ft (line 6) | function ft(e,t,n){e.isStatic=!0,e.key=t,e.isOnce=n}
function mt (line 6) | function mt(e,t){if(t&&s(t)){var n=e.on=e.on?v({},e.on):{};for(var r in ...
function ht (line 6) | function ht(e){e._vnode=null,e._staticTrees=null;var t=e.$vnode=e.$optio...
function pt (line 6) | function pt(e,t){var n=e.$options=Object.create(e.constructor.options);n...
function yt (line 6) | function yt(e){var t=e.options;if(e.super){var n=yt(e.super);if(n!==e.su...
function vt (line 6) | function vt(e){var t,n=e.options,r=e.extendOptions,a=e.sealedOptions;for...
function Mt (line 6) | function Mt(e,t,n){if(Array.isArray(e)){var r=[];n=Array.isArray(n)?n:[n...
function gt (line 6) | function gt(e){this._init(e)}
function Lt (line 6) | function Lt(e){e.use=function(e){var t=this._installedPlugins||(this._in...
function Yt (line 6) | function Yt(e){e.mixin=function(e){return this.options=U(this.options,e)...
function kt (line 6) | function kt(e){e.cid=0;var t=1;e.extend=function(e){e=e||{};var n=this,r...
function bt (line 6) | function bt(e){var t=e.options.props;for(var n in t)Pe(e.prototype,"_pro...
function wt (line 6) | function wt(e){var t=e.options.computed;for(var n in t)Re(e.prototype,n,...
function Dt (line 6) | function Dt(e){wa.forEach(function(t){e[t]=function(e,n){return n?("comp...
function Tt (line 6) | function Tt(e){return e&&(e.Ctor.options.name||e.tag)}
function St (line 6) | function St(e,t){return Array.isArray(e)?e.indexOf(t)>-1:"string"==typeo...
function jt (line 6) | function jt(e,t,n){for(var r in e){var a=e[r];if(a){var i=Tt(a.component...
function xt (line 6) | function xt(e){e&&e.componentInstance.$destroy()}
function Ht (line 6) | function Ht(e){for(var t=e.data,r=e,a=e;n(a.componentInstance);)(a=a.com...
function Ot (line 6) | function Ot(e,t){return{staticClass:Et(e.staticClass,t.staticClass),clas...
function At (line 6) | function At(e,t){return n(e)||n(t)?Et(e,Pt(t)):""}
function Et (line 6) | function Et(e,t){return e?t?e+" "+t:e:t||""}
function Pt (line 6) | function Pt(e){return Array.isArray(e)?$t(e):o(e)?Ct(e):"string"==typeof...
function $t (line 6) | function $t(e){for(var t,r="",a=0,i=e.length;a<i;a++)n(t=Pt(e[a]))&&""!=...
function Ct (line 6) | function Ct(e){var t="";for(var n in e)e[n]&&(t&&(t+=" "),t+=n);return t}
function Ft (line 6) | function Ft(e){return Bi(e)?"svg":"math"===e?"math":void 0}
function Wt (line 6) | function Wt(e){if("string"==typeof e){return document.querySelector(e)||...
function It (line 6) | function It(e,t){var n=e.data.ref;if(n){var r=e.context,a=e.componentIns...
function Rt (line 6) | function Rt(t,a){return t.key===a.key&&(t.tag===a.tag&&t.isComment===a.i...
function Nt (line 6) | function Nt(e,t){if("input"!==e.tag)return!0;var r;return(n(r=e.data)&&n...
function zt (line 6) | function zt(e,t,r){var a,i,o={};for(a=t;a<=r;++a)n(i=e[a].key)&&(o[i]=a)...
function Jt (line 6) | function Jt(e,t){(e.data.directives||t.data.directives)&&Ut(e,t)}
function Ut (line 6) | function Ut(e,t){var n,r,a,i=e===eo,o=t===eo,s=Vt(e.data.directives,e.co...
function Vt (line 6) | function Vt(e,t){var n=Object.create(null);if(!e)return n;var r,a;for(r=...
function Gt (line 6) | function Gt(e){return e.rawName||e.name+"."+Object.keys(e.modifiers||{})...
function qt (line 6) | function qt(e,t,n,r,a){var i=e.def&&e.def[t];if(i)try{i(n.elm,e,n,r,a)}c...
function Bt (line 6) | function Bt(t,r){var a=r.componentOptions;if(!(n(a)&&!1===a.Ctor.options...
function Kt (line 6) | function Kt(e,t,n){Ni(t)?Vi(n)?e.removeAttribute(t):e.setAttribute(t,t):...
function Zt (line 6) | function Zt(t,r){var a=r.elm,i=r.data,o=t.data;if(!(e(i.staticClass)&&e(...
function Qt (line 6) | function Qt(e){function t(){(o||(o=[])).push(e.slice(m,a).trim()),m=a+1}...
function Xt (line 6) | function Xt(e,t){var n=t.indexOf("(");return n<0?'_f("'+t+'")('+e+")":'_...
function en (line 6) | function en(e){console.error("[Vue compiler]: "+e)}
function tn (line 6) | function tn(e,t){return e?e.map(function(e){return e[t]}).filter(functio...
function nn (line 6) | function nn(e,t,n){(e.props||(e.props=[])).push({name:t,value:n})}
function rn (line 6) | function rn(e,t,n){(e.attrs||(e.attrs=[])).push({name:t,value:n})}
function an (line 6) | function an(e,t,n,r,a,i){(e.directives||(e.directives=[])).push({name:t,...
function on (line 6) | function on(e,t,n,r,a,i){r&&r.capture&&(delete r.capture,t="!"+t),r&&r.o...
function sn (line 6) | function sn(e,t,n){var r=un(e,":"+t)||un(e,"v-bind:"+t);if(null!=r)retur...
function un (line 6) | function un(e,t){var n;if(null!=(n=e.attrsMap[t]))for(var r=e.attrsList,...
function dn (line 6) | function dn(e,t,n){var r=n||{},a=r.number,i="$$v";r.trim&&(i="(typeof $$...
function cn (line 6) | function cn(e,t){var n=ln(e);return null===n.idx?e+"="+t:"$set("+n.exp+"...
function ln (line 6) | function ln(e){if(xi=e,ji=xi.length,Oi=Ai=Ei=0,e.indexOf("[")<0||e.lastI...
function _n (line 6) | function _n(){return xi.charCodeAt(++Oi)}
function fn (line 6) | function fn(){return Oi>=ji}
function mn (line 6) | function mn(e){return 34===e||39===e}
function hn (line 6) | function hn(e){var t=1;for(Ai=Oi;!fn();)if(e=_n(),mn(e))pn(e);else if(91...
function pn (line 6) | function pn(e){for(var t=e;!fn()&&(e=_n())!==t;);}
function yn (line 6) | function yn(e,t,n){var r=n&&n.number,a=sn(e,"value")||"null",i=sn(e,"tru...
function vn (line 6) | function vn(e,t,n){var r=n&&n.number,a=sn(e,"value")||"null";nn(e,"check...
function Mn (line 6) | function Mn(e,t,n){var r='var $$selectedVal = Array.prototype.filter.cal...
function gn (line 6) | function gn(e,t,n){var r=e.attrsMap.type,a=n||{},i=a.lazy,o=a.number,s=a...
function Ln (line 6) | function Ln(e){var t;n(e[uo])&&(e[t=Ea?"change":"input"]=[].concat(e[uo]...
function Yn (line 6) | function Yn(e,t,n,r,a){if(n){var i=t,o=$i;t=function(n){null!==(1===argu...
function kn (line 6) | function kn(e,t,n,r){(r||$i).removeEventListener(e,t,n)}
function bn (line 6) | function bn(t,n){if(!e(t.data.on)||!e(n.data.on)){var r=n.data.on||{},a=...
function wn (line 6) | function wn(t,r){if(!e(t.data.domProps)||!e(r.data.domProps)){var a,i,o=...
function Dn (line 6) | function Dn(e,t,n){return!e.composing&&("option"===t.tag||Tn(e,n)||Sn(e,...
function Tn (line 6) | function Tn(e,t){var n=!0;try{n=document.activeElement!==e}catch(e){}ret...
function Sn (line 6) | function Sn(e,t){var r=e.value,a=e._vModifiers;return n(a)&&a.number?l(r...
function jn (line 6) | function jn(e){var t=xn(e.style);return e.staticStyle?v(e.staticStyle,t):t}
function xn (line 6) | function xn(e){return Array.isArray(e)?M(e):"string"==typeof e?fo(e):e}
function Hn (line 6) | function Hn(e,t){var n,r={};if(t)for(var a=e;a.componentInstance;)(a=a.c...
function On (line 6) | function On(t,r){var a=r.data,i=t.data;if(!(e(a.staticStyle)&&e(a.style)...
function An (line 6) | function An(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.s...
function En (line 6) | function En(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.s...
function Pn (line 6) | function Pn(e){if(e){if("object"==typeof e){var t={};return!1!==e.css&&v...
function $n (line 6) | function $n(e){So(function(){So(e)})}
function Cn (line 6) | function Cn(e,t){var n=e._transitionClasses||(e._transitionClasses=[]);n...
function Fn (line 6) | function Fn(e,t){e._transitionClasses&&f(e._transitionClasses,t),En(e,t)}
function Wn (line 6) | function Wn(e,t,n){var r=In(e,t),a=r.type,i=r.timeout,o=r.propCount;if(!...
function In (line 6) | function In(e,t){var n,r=window.getComputedStyle(e),a=r[bo+"Delay"].spli...
function Rn (line 6) | function Rn(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max.a...
function Nn (line 6) | function Nn(e){return 1e3*Number(e.slice(0,-1))}
function zn (line 6) | function zn(t,r){var a=t.elm;n(a._leaveCb)&&(a._leaveCb.cancelled=!0,a._...
function Jn (line 6) | function Jn(t,r){function a(){b.cancelled||(t.data.show||((i.parentNode....
function Un (line 6) | function Un(e){return"number"==typeof e&&!isNaN(e)}
function Vn (line 6) | function Vn(t){if(e(t))return!1;var r=t.fns;return n(r)?Vn(Array.isArray...
function Gn (line 6) | function Gn(e,t){!0!==t.data.show&&zn(t)}
function qn (line 6) | function qn(e,t,n){var r=t.value,a=e.multiple;if(!a||Array.isArray(r)){f...
function Bn (line 6) | function Bn(e){return"_value"in e?e._value:e.value}
function Kn (line 6) | function Kn(e){e.target.composing=!0}
function Zn (line 6) | function Zn(e){e.target.composing&&(e.target.composing=!1,Qn(e.target,"i...
function Qn (line 6) | function Qn(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,...
function Xn (line 6) | function Xn(e){return!e.componentInstance||e.data&&e.data.transition?e:X...
function er (line 6) | function er(e){var t=e&&e.componentOptions;return t&&t.Ctor.options.abst...
function tr (line 6) | function tr(e){var t={},n=e.$options;for(var r in n.propsData)t[r]=e[r];...
function nr (line 6) | function nr(e,t){if(/\d-keep-alive$/.test(t.tag))return e("keep-alive",{...
function rr (line 6) | function rr(e){for(;e=e.parent;)if(e.data.transition)return!0}
function ar (line 6) | function ar(e,t){return t.key===e.key&&t.tag===e.tag}
function ir (line 6) | function ir(e){return e.isComment&&e.asyncFactory}
function or (line 6) | function or(e){e.elm._moveCb&&e.elm._moveCb(),e.elm._enterCb&&e.elm._ent...
function sr (line 6) | function sr(e){e.data.newPos=e.elm.getBoundingClientRect()}
function ur (line 6) | function ur(e){var t=e.data.pos,n=e.data.newPos,r=t.left-n.left,a=t.top-...
function dr (line 6) | function dr(e,t){var n=t?Ro(t):Wo;if(n.test(e)){for(var r,a,i=[],o=n.las...
function cr (line 6) | function cr(e,t){var n=t?Ys:Ls;return e.replace(n,function(e){return gs[...
function lr (line 6) | function lr(e,t){function n(t){c+=t,e=e.substring(t)}function r(e,n,r){v...
function _r (line 6) | function _r(e,t){function n(e){e.pre&&(s=!1),fs(e.tag)&&(u=!1)}us=t.warn...
function fr (line 6) | function fr(e){null!=un(e,"v-pre")&&(e.pre=!0)}
function mr (line 6) | function mr(e){var t=e.attrsList.length;if(t)for(var n=e.attrs=new Array...
function hr (line 6) | function hr(e){var t=sn(e,"key");t&&(e.key=t)}
function pr (line 6) | function pr(e){var t=sn(e,"ref");t&&(e.ref=t,e.refInFor=Dr(e))}
function yr (line 6) | function yr(e){var t;if(t=un(e,"v-for")){var n=t.match(Ts);if(!n)return;...
function vr (line 6) | function vr(e){var t=un(e,"v-if");if(t)e.if=t,Lr(e,{exp:t,block:e});else...
function Mr (line 6) | function Mr(e,t){var n=gr(t.children);n&&n.if&&Lr(n,{exp:e.elseif,block:...
function gr (line 6) | function gr(e){for(var t=e.length;t--;){if(1===e[t].type)return e[t];e.p...
function Lr (line 6) | function Lr(e,t){e.ifConditions||(e.ifConditions=[]),e.ifConditions.push...
function Yr (line 6) | function Yr(e){null!=un(e,"v-once")&&(e.once=!0)}
function kr (line 6) | function kr(e){if("slot"===e.tag)e.slotName=sn(e,"name");else{var t=sn(e...
function br (line 6) | function br(e){var t;(t=sn(e,"is"))&&(e.component=t),null!=un(e,"inline-...
function wr (line 6) | function wr(e){var t,n,r,a,i,o,s,u=e.attrsList;for(t=0,n=u.length;t<n;t+...
function Dr (line 6) | function Dr(e){for(var t=e;t;){if(void 0!==t.for)return!0;t=t.parent}ret...
function Tr (line 6) | function Tr(e){var t=e.match(Hs);if(t){var n={};return t.forEach(functio...
function Sr (line 6) | function Sr(e){for(var t={},n=0,r=e.length;n<r;n++)t[e[n].name]=e[n].val...
function jr (line 6) | function jr(e){return"script"===e.tag||"style"===e.tag}
function xr (line 6) | function xr(e){return"style"===e.tag||"script"===e.tag&&(!e.attrsMap.typ...
function Hr (line 6) | function Hr(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];As.test(r.nam...
function Or (line 6) | function Or(e,t){e&&(ps=Ps(t.staticKeys||""),ys=t.isReservedTag||Ya,Ar(e...
function Ar (line 6) | function Ar(e){if(e.static=Pr(e),1===e.type){if(!ys(e.tag)&&"slot"!==e.t...
function Er (line 6) | function Er(e,t){if(1===e.type){if((e.static||e.once)&&(e.staticInFor=t)...
function Pr (line 6) | function Pr(e){return 2!==e.type&&(3===e.type||!(!e.pre&&(e.hasBindings|...
function $r (line 6) | function $r(e){for(;e.parent;){if("template"!==(e=e.parent).tag)return!1...
function Cr (line 6) | function Cr(e,t,n){var r=t?"nativeOn:{":"on:{";for(var a in e){r+='"'+a+...
function Fr (line 6) | function Fr(e,t){if(!t)return"function(){}";if(Array.isArray(t))return"[...
function Wr (line 6) | function Wr(e){return"if(!('button' in $event)&&"+e.map(Ir).join("&&")+"...
function Ir (line 6) | function Ir(e){var t=parseInt(e,10);if(t)return"$event.keyCode!=="+t;var...
function Rr (line 6) | function Rr(e,t){var n=new Ns(t);return{render:"with(this){return "+(e?N...
function Nr (line 6) | function Nr(e,t){if(e.staticRoot&&!e.staticProcessed)return zr(e,t);if(e...
function zr (line 6) | function zr(e,t){return e.staticProcessed=!0,t.staticRenderFns.push("wit...
function Jr (line 6) | function Jr(e,t){if(e.onceProcessed=!0,e.if&&!e.ifProcessed)return Ur(e,...
function Ur (line 6) | function Ur(e,t,n,r){return e.ifProcessed=!0,Vr(e.ifConditions.slice(),t...
function Vr (line 6) | function Vr(e,t,n,r){function a(e){return n?n(e,t):e.once?Jr(e,t):Nr(e,t...
function Gr (line 6) | function Gr(e,t,n,r){var a=e.for,i=e.alias,o=e.iterator1?","+e.iterator1...
function qr (line 6) | function qr(e,t){var n="{",r=Br(e,t);r&&(n+=r+","),e.key&&(n+="key:"+e.k...
function Br (line 6) | function Br(e,t){var n=e.directives;if(n){var r,a,i,o,s="directives:[",u...
function Kr (line 6) | function Kr(e,t){var n=e.children[0];if(1===n.type){var r=Rr(n,t.options...
function Zr (line 6) | function Zr(e,t){return"scopedSlots:_u(["+Object.keys(e).map(function(n)...
function Qr (line 6) | function Qr(e,t,n){return t.for&&!t.forProcessed?Xr(e,t,n):"{key:"+e+",f...
function Xr (line 6) | function Xr(e,t,n){var r=t.for,a=t.alias,i=t.iterator1?","+t.iterator1:"...
function ea (line 6) | function ea(e,t,n,r,a){var i=e.children;if(i.length){var o=i[0];if(1===i...
function ta (line 6) | function ta(e,t){for(var n=0,r=0;r<e.length;r++){var a=e[r];if(1===a.typ...
function na (line 6) | function na(e){return void 0!==e.for||"template"===e.tag||"slot"===e.tag}
function ra (line 6) | function ra(e,t){return 1===e.type?Nr(e,t):3===e.type&&e.isComment?ia(e)...
function aa (line 6) | function aa(e){return"_v("+(2===e.type?e.expression:da(JSON.stringify(e....
function ia (line 6) | function ia(e){return"_e("+JSON.stringify(e.text)+")"}
function oa (line 6) | function oa(e,t){var n=e.slotName||'"default"',r=ea(e,t),a="_t("+n+(r?",...
function sa (line 6) | function sa(e,t,n){var r=t.inlineTemplate?null:ea(t,n,!0);return"_c("+e+...
function ua (line 6) | function ua(e){for(var t="",n=0;n<e.length;n++){var r=e[n];t+='"'+r.name...
function da (line 6) | function da(e){return e.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"...
function ca (line 6) | function ca(e,t){try{return new Function(e)}catch(n){return t.push({err:...
function la (line 6) | function la(e){var t=Object.create(null);return function(n,r,a){var i=(r...
function _a (line 6) | function _a(e){if(e.outerHTML)return e.outerHTML;var t=document.createEl...
function e (line 6) | function e(){r=!1;var e=n.slice(0);n.length=0;for(var t=0;t<e.length;t++...
function e (line 6) | function e(){this.set=Object.create(null)}
function n (line 6) | function n(){r.$off(e,n),t.apply(r,arguments)}
function a (line 6) | function a(e){return new ii(x.tagName(e).toLowerCase(),{},[],void 0,e)}
function o (line 6) | function o(e,t){function n(){0==--n.listeners&&s(e)}return n.listeners=t,n}
function s (line 6) | function s(e){var t=x.parentNode(e);n(t)&&x.removeChild(t,e)}
function u (line 6) | function u(e,t,a,i,o){if(e.isRootInsert=!o,!d(e,t,a,i)){var s=e.data,u=e...
function d (line 6) | function d(e,t,a,i){var o=e.data;if(n(o)){var s=n(e.componentInstance)&&...
function c (line 6) | function c(e,t){n(e.data.pendingInsert)&&(t.push.apply(t,e.data.pendingI...
function l (line 6) | function l(e,t,r,a){for(var i,o=e;o.componentInstance;)if(o=o.componentI...
function f (line 6) | function f(e,t,r){n(e)&&(n(r)?r.parentNode===e&&x.insertBefore(e,t,r):x....
function m (line 6) | function m(e,t,n){if(Array.isArray(t))for(var r=0;r<t.length;++r)u(t[r],...
function h (line 6) | function h(e){for(;e.componentInstance;)e=e.componentInstance._vnode;ret...
function p (line 6) | function p(e,t){for(var r=0;r<S.create.length;++r)S.create[r](eo,e);n(D=...
function y (line 6) | function y(e){for(var t,r=e;r;)n(t=r.context)&&n(t=t.$options._scopeId)&...
function v (line 6) | function v(e,t,n,r,a,i){for(;r<=a;++r)u(n[r],i,e,t)}
function M (line 6) | function M(e){var t,r,a=e.data;if(n(a))for(n(t=a.hook)&&n(t=t.destroy)&&...
function g (line 6) | function g(e,t,r,a){for(;r<=a;++r){var i=t[r];n(i)&&(n(i.tag)?(L(i),M(i)...
function L (line 6) | function L(e,t){if(n(t)||n(e.data)){var r,a=S.remove.length+1;for(n(t)?t...
function Y (line 6) | function Y(t,r,a,i,o){for(var s,d,c,l=0,_=0,f=r.length-1,m=r[0],h=r[f],p...
function k (line 6) | function k(t,a,i,o){if(t!==a){var s=a.elm=t.elm;if(r(t.isAsyncPlaceholde...
function b (line 6) | function b(e,t,a){if(r(a)&&n(e.parent))e.parent.data.pendingInsert=t;els...
function w (line 6) | function w(e,t,a){if(r(t.isComment)&&n(t.asyncFactory))return t.elm=e,t....
function n (line 6) | function n(n,r){var a=Object.create(t),i=[],o=[];if(a.warn=function(e,t)...
function r (line 6) | function r(e,t,n,r,i){if(!t||!t.dependencies)return[];i||(i=[]),n||(n={}...
function a (line 6) | function a(e,n,a,u,d){var c;switch(u||(u={}),n){case"$options":return a;...
function r (line 6) | function r(e){w&&(e._devtoolHook=w,w.emit("vuex:init",e),w.on("vuex:trav...
function a (line 6) | function a(e,t){Object.keys(e).forEach(function(n){return t(e[n],n)})}
function i (line 6) | function i(e){return null!==e&&"object"==typeof e}
function o (line 6) | function o(e){return e&&"function"==typeof e.then}
function s (line 6) | function s(e,t){if(!e)throw new Error("[vuex] "+t)}
function u (line 6) | function u(e,t){if(e.update(t),t.modules)for(var n in t.modules){if(!e.g...
function d (line 6) | function d(e,t){e._actions=Object.create(null),e._mutations=Object.creat...
function c (line 6) | function c(e,t,n){var r=e._vm;e.getters={};var i=e._wrappedGetters,o={};...
function l (line 6) | function l(e,t,n,r,a){var i=!n.length,o=e._modules.getNamespace(n);if(r....
function _ (line 6) | function _(e,t,n){var r=""===t,a={dispatch:r?e.dispatch:function(n,r,a){...
function f (line 6) | function f(e,t){var n={},r=t.length;return Object.keys(e.getters).forEac...
function m (line 6) | function m(e,t,n,r){(e._mutations[t]||(e._mutations[t]=[])).push(functio...
function h (line 6) | function h(e,t,n,r){(e._actions[t]||(e._actions[t]=[])).push(function(t,...
function p (line 6) | function p(e,t,n,r){if(e._wrappedGetters[t])return void console.error("[...
function y (line 6) | function y(e){e._vm.$watch(function(){return this._data.$$state},functio...
function v (line 6) | function v(e,t){return t.length?t.reduce(function(e,t){return e[t]},e):e}
function M (line 6) | function M(e,t,n){return i(e)&&e.type&&(n=t,t=e,e=e.type),s("string"==ty...
function g (line 6) | function g(e){if(j)return void console.error("[vuex] already installed. ...
function L (line 6) | function L(e){return Array.isArray(e)?e.map(function(e){return{key:e,val...
function Y (line 6) | function Y(e){return function(t,n){return"string"!=typeof t?(n=t,t=""):"...
function k (line 6) | function k(e,t,n){var r=e._modulesNamespaceMap[n];return r||console.erro...
function t (line 11) | function t(){var e=this.$options;e.store?this.$store=e.store:e.parent&&e...
function r (line 11) | function r(e){this.state=U,this.value=void 0,this.deferred=[];var t=this...
function a (line 11) | function a(e,t){e instanceof Promise?this.promise=e:this.promise=new Pro...
function i (line 11) | function i(e){"undefined"!=typeof console&&X&&console.warn("[VueResource...
function o (line 11) | function o(e){"undefined"!=typeof console&&console.error(e)}
function s (line 11) | function s(e,t){return q(e,t)}
function u (line 11) | function u(e){return e?e.replace(/^\s*|\s*$/g,""):""}
function d (line 11) | function d(e,t){return e&&void 0===t?e.replace(/\s+$/,""):e&&t?e.replace...
function c (line 11) | function c(e){return e?e.toLowerCase():""}
function l (line 11) | function l(e){return e?e.toUpperCase():""}
function _ (line 11) | function _(e){return"string"==typeof e}
function f (line 11) | function f(e){return"function"==typeof e}
function m (line 11) | function m(e){return null!==e&&"object"==typeof e}
function h (line 11) | function h(e){return m(e)&&Object.getPrototypeOf(e)==Object.prototype}
function p (line 11) | function p(e){return"undefined"!=typeof Blob&&e instanceof Blob}
function y (line 11) | function y(e){return"undefined"!=typeof FormData&&e instanceof FormData}
function v (line 11) | function v(e,t,n){var r=a.resolve(e);return arguments.length<2?r:r.then(...
function M (line 11) | function M(e,t,n){return n=n||{},f(n)&&(n=n.call(t)),L(e.bind({$vm:t,$op...
function g (line 11) | function g(e,t){var n,r;if(ne(e))for(n=0;n<e.length;n++)t.call(e[n],e[n]...
function L (line 11) | function L(e){return Q.call(arguments,1).forEach(function(t){b(e,t,!0)}),e}
function Y (line 11) | function Y(e){return Q.call(arguments,1).forEach(function(t){for(var n i...
function k (line 11) | function k(e){return Q.call(arguments,1).forEach(function(t){b(e,t)}),e}
function b (line 11) | function b(e,t,n){for(var r in t)n&&(h(t[r])||ne(t[r]))?(h(t[r])&&!h(e[r...
function w (line 11) | function w(e,t,n){var r=D(e),a=r.expand(t);return n&&n.push.apply(n,r.va...
function D (line 11) | function D(e){var t=["+","#",".","/",";","?","&"],n=[];return{vars:n,exp...
function T (line 11) | function T(e,t,n,r){var a=e[n],i=[];if(S(a)&&""!==a)if("string"==typeof ...
function S (line 11) | function S(e){return void 0!==e&&null!==e}
function j (line 11) | function j(e){return";"===e||"&"===e||"?"===e}
function x (line 11) | function x(e,t,n){return t="+"===e||"#"===e?H(t):encodeURIComponent(t),n...
function H (line 11) | function H(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(e){retur...
function O (line 11) | function O(e,t){var n,r=this||{},a=e;return _(e)&&(a={url:e,params:t}),a...
function A (line 11) | function A(e,t,n){return function(r){return e.call(n,r,t)}}
function E (line 11) | function E(e,t,n){var r,a=ne(t),i=h(t);g(t,function(t,o){r=m(t)||ne(t),n...
function P (line 11) | function P(e){var t=e.match(/^\[|^\{(?!\{)/),n={"[":/]$/,"{":/}$/};retur...
function $ (line 11) | function $(e,t){t((e.client||(ee?ye:ve))(e))}
function C (line 11) | function C(e,t){return Object.keys(e).reduce(function(e,n){return c(t)==...
function F (line 11) | function F(e){if(/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeErro...
function W (line 11) | function W(e){return new a(function(t){var n=new FileReader;n.readAsText...
function I (line 11) | function I(e){return 0===e.type.indexOf("text")||-1!==e.type.indexOf("js...
function R (line 11) | function R(e){var t=this||{},n=Me(t.$vm);return Y(e||{},t.$options,R.opt...
function N (line 11) | function N(e,t,n,r){var a=this||{},i={};return n=re({},N.actions,n),g(n,...
function z (line 11) | function z(e,t){var n,r=re({},e),a={};switch(t.length){case 2:a=t[0],n=t...
function J (line 11) | function J(e){J.installed||(te(e),e.url=O,e.http=R,e.resource=N,e.Promis...
function t (line 16) | function t(t){return new a(function(a,s){function u(){n=r.pop(),f(n)?n.c...
function r (line 16) | function r(e,t){this._id=e,this._clearFn=t}
function r (line 16) | function r(e,t){}
function a (line 16) | function a(e){return Object.prototype.toString.call(e).indexOf("Error")>-1}
function i (line 16) | function i(e,t){switch(typeof t){case"undefined":return;case"object":ret...
function o (line 16) | function o(e,t,n){void 0===t&&(t={});var r,a=n||s;try{r=a(e||"")}catch(e...
function s (line 16) | function s(e){var t={};return(e=e.trim().replace(/^(\?|#|&)/,""))?(e.spl...
function u (line 16) | function u(e){var t=e?Object.keys(e).map(function(t){var n=e[t];if(void ...
function d (line 16) | function d(e,t,n,r){var a=r&&r.options.stringifyQuery,i={name:t.name||e&...
function c (line 16) | function c(e){for(var t=[];e;)t.unshift(e),e=e.parent;return t}
function l (line 16) | function l(e,t){var n=e.path,r=e.query;void 0===r&&(r={});var a=e.hash;v...
function _ (line 16) | function _(e,t){return t===Ce?e===t:!!t&&(e.path&&t.path?e.path.replace(...
function f (line 16) | function f(e,t){void 0===e&&(e={}),void 0===t&&(t={});var n=Object.keys(...
function m (line 16) | function m(e,t){return 0===e.path.replace($e,"/").indexOf(t.path.replace...
function h (line 16) | function h(e,t){for(var n in t)if(!(n in e))return!1;return!0}
function p (line 16) | function p(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||e.default...
function y (line 16) | function y(e){if(e)for(var t,n=0;n<e.length;n++){if(t=e[n],"a"===t.tag)r...
function v (line 16) | function v(e){if(!v.installed){v.installed=!0,je=e;var t=function(e){ret...
function M (line 16) | function M(e,t,n){var r=e.charAt(0);if("/"===r)return e;if("?"===r||"#"=...
function g (line 16) | function g(e){var t="",n="",r=e.indexOf("#");r>=0&&(t=e.slice(r),e=e.sli...
function L (line 16) | function L(e){return e.replace(/\/\//g,"/")}
function Y (line 16) | function Y(e,t){for(var n,r=[],a=0,i=0,o="",s=t&&t.delimiter||"/";null!=...
function k (line 16) | function k(e,t){return D(Y(e,t))}
function b (line 16) | function b(e){return encodeURI(e).replace(/[\/?#]/g,function(e){return"%...
function w (line 16) | function w(e){return encodeURI(e).replace(/[?#]/g,function(e){return"%"+...
function D (line 16) | function D(e){for(var t=new Array(e.length),n=0;n<e.length;n++)"object"=...
function T (line 16) | function T(e){return e.replace(/([.+*?=^!:${}()[\]|\/\\])/g,"\\$1")}
function S (line 16) | function S(e){return e.replace(/([=!:$\/()])/g,"\\$1")}
function j (line 16) | function j(e,t){return e.keys=t,e}
function x (line 16) | function x(e){return e.sensitive?"":"i"}
function H (line 16) | function H(e,t){var n=e.source.match(/\((?!\?)/g);if(n)for(var r=0;r<n.l...
function O (line 16) | function O(e,t,n){for(var r=[],a=0;a<e.length;a++)r.push(P(e[a],t,n).sou...
function A (line 16) | function A(e,t,n){return E(Y(e,n),t,n)}
function E (line 16) | function E(e,t,n){Ne(t)||(n=t||n,t=[]),n=n||{};for(var r=n.strict,a=!1!=...
function P (line 16) | function P(e,t,n){return Ne(t)||(n=t||n,t=[]),n=n||{},e instanceof RegEx...
function $ (line 16) | function $(e,t,n){try{return(Be[e]||(Be[e]=ze.compile(e)))(t||{},{pretty...
function C (line 16) | function C(e,t,n,r){var a=t||[],i=n||Object.create(null),o=r||Object.cre...
function F (line 16) | function F(e,t,n,r,a,i){var o=r.path,s=r.name,u=I(o,a),d=r.pathToRegexpO...
function W (line 16) | function W(e,t){var n=ze(e,[],t);return n}
function I (line 16) | function I(e,t){return e=e.replace(/\/$/,""),"/"===e[0]?e:null==t?e:L(t....
function R (line 16) | function R(e,t,n,r){var a="string"==typeof e?{path:e}:e;if(a.name||a._no...
function N (line 16) | function N(e,t){for(var n in t)e[n]=t[n];return e}
function z (line 16) | function z(e,t){function n(e){C(e,u,c,l)}function r(e,n,r){var a=R(e,n,!...
function J (line 16) | function J(e,t,n){var r=t.match(e);if(!r)return!1;if(!n)return!0;for(var...
function U (line 16) | function U(e,t){return M(e,t.parent?t.parent.path:"/",!0)}
function V (line 16) | function V(){window.addEventListener("popstate",function(e){q(),e.state&...
function G (line 16) | function G(e,t,n,r){if(e.app){var a=e.options.scrollBehavior;a&&e.app.$n...
function q (line 16) | function q(){var e=ne();e&&(Ke[e]={x:window.pageXOffset,y:window.pageYOf...
function B (line 16) | function B(){var e=ne();if(e)return Ke[e]}
function K (line 16) | function K(e,t){var n=document.documentElement,r=n.getBoundingClientRect...
function Z (line 16) | function Z(e){return ee(e.x)||ee(e.y)}
function Q (line 16) | function Q(e){return{x:ee(e.x)?e.x:window.pageXOffset,y:ee(e.y)?e.y:wind...
function X (line 16) | function X(e){return{x:ee(e.x)?e.x:0,y:ee(e.y)?e.y:0}}
function ee (line 16) | function ee(e){return"number"==typeof e}
function te (line 16) | function te(){return Qe.now().toFixed(3)}
function ne (line 16) | function ne(){return Xe}
function re (line 16) | function re(e){Xe=e}
function ae (line 16) | function ae(e,t){q();var n=window.history;try{t?n.replaceState({key:Xe},...
function ie (line 16) | function ie(e){ae(e,!0)}
function oe (line 16) | function oe(e,t,n){var r=function(a){a>=e.length?n():e[a]?t(e[a],functio...
function se (line 16) | function se(e){return function(t,n,r){var i=!1,o=0,s=null;ue(e,function(...
function ue (line 16) | function ue(e,t){return de(e.map(function(e){return Object.keys(e.compon...
function de (line 16) | function de(e){return Array.prototype.concat.apply([],e)}
function ce (line 16) | function ce(e){var t=!1;return function(){for(var n=[],r=arguments.lengt...
function le (line 16) | function le(e){if(!e)if(Re){var t=document.querySelector("base");e=t&&t....
function _e (line 16) | function _e(e,t){var n,r=Math.max(e.length,t.length);for(n=0;n<r&&e[n]==...
function fe (line 16) | function fe(e,t,n,r){var a=ue(e,function(e,r,a,i){var o=me(e,t);if(o)ret...
function me (line 16) | function me(e,t){return"function"!=typeof e&&(e=je.extend(e)),e.options[t]}
function he (line 16) | function he(e){return fe(e,"beforeRouteLeave",ye,!0)}
function pe (line 16) | function pe(e){return fe(e,"beforeRouteUpdate",ye)}
function ye (line 16) | function ye(e,t){if(t)return function(){return e.apply(t,arguments)}}
function ve (line 16) | function ve(e,t,n){return fe(e,"beforeRouteEnter",function(e,r,a,i){retu...
function Me (line 16) | function Me(e,t,n,r,a){return function(i,o,s){return e(i,o,function(e){s...
function ge (line 16) | function ge(e,t,n,r){t[n]?e(t[n]):r()&&setTimeout(function(){ge(e,t,n,r)...
function Le (line 16) | function Le(e){var t=window.location.pathname;return e&&0===t.indexOf(e)...
function Ye (line 16) | function Ye(e){var t=Le(e);if(!/^\/#/.test(t))return window.location.rep...
function ke (line 16) | function ke(){var e=be();return"/"===e.charAt(0)||(De("/"+e),!1)}
function be (line 16) | function be(){var e=window.location.href,t=e.indexOf("#");return-1===t?"...
function we (line 16) | function we(e){window.location.hash=e}
function De (line 16) | function De(e){var t=window.location.href,n=t.indexOf("#"),r=n>=0?t.slic...
function Te (line 16) | function Te(e,t){return e.push(t),function(){var n=e.indexOf(t);n>-1&&e....
function Se (line 16) | function Se(e,t,n){var r="hash"===n?"#"+t:t;return e?L(e+"/"+r):r}
function t (line 16) | function t(t,n){var r=this;e.call(this,t,n);var a=t.options.scrollBehavi...
function t (line 16) | function t(t,n,r){e.call(this,t,n),r&&Ye(this.base)||ke()}
function t (line 16) | function t(t,n){e.call(this,t,n),this.stack=[],this.index=-1}
function r (line 16) | function r(e){return null!==e&&"object"==typeof e}
function a (line 16) | function a(e){return k.call(e)===b}
function i (line 16) | function i(e){return null===e||void 0===e}
function o (line 16) | function o(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var ...
function s (line 16) | function s(e){return e?e>1?1:0:1}
function u (line 16) | function u(e,t){return e=Math.abs(e),2===t?s(e):e?Math.min(e,2):0}
function d (line 16) | function d(e,t){if(!e&&"string"!=typeof e)return null;var n=e.split("|")...
function c (line 16) | function c(e){return JSON.parse(JSON.stringify(e))}
function l (line 16) | function l(e,t){if(e.length){var n=e.indexOf(t);if(n>-1)return e.splice(...
function _ (line 16) | function _(e){e.prototype.$t=function(e){for(var t=[],n=arguments.length...
function f (line 16) | function f(e){Y=e;Y.version&&Number(Y.version.split(".")[0]);f.installed...
function m (line 16) | function m(e){for(var t=[],n=0,r="";n<e.length;){var a=e[n++];if("{"===a...
function h (line 16) | function h(e,t){var n=[],a=0,i=Array.isArray(t)?"list":r(t)?"named":"unk...
function p (line 16) | function p(e){return z.test(e)}
function y (line 16) | function y(e){var t=e.charCodeAt(0);return t!==e.charCodeAt(e.length-1)|...
function v (line 16) | function v(e){if(void 0===e||null===e)return"eof";var t=e.charCodeAt(0);...
function M (line 16) | function M(e){var t=e.trim();return("0"!==e.charAt(0)||!isNaN(e))&&(p(t)...
function g (line 16) | function g(e){var t,n,r,a,i,o,s,u=[],d=-1,c=$,l=0,_=[];for(_[A]=function...
function L (line 16) | function L(e){return!!Array.isArray(e)&&0===e.length}
function r (line 16) | function r(e,t,n){var r=e.$$hooks;if(!r[t]){for(var i=0,o=e;o.$$parent&&...
function t (line 21) | function t(e){return e.replace(/-/gi,"")}
function n (line 21) | function n(){return[].concat(w.id)}
function r (line 21) | function r(e,r){var a=t(r);return n().length>1?a+"."+e:e}
function a (line 21) | function a(e){return b(w,e)}
function i (line 21) | function i(e){for(var t=arguments.length,a=Array(t>1?t-1:0),i=1;i<t;i++)...
function o (line 21) | function o(e){var t=Object.keys(e).reduce(function(t,n,r,a){return t+=n+...
function s (line 21) | function s(e,t){if(!e)return void Y("Is not possible to track the curren...
function u (line 21) | function u(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=argu...
function d (line 21) | function d(){if(void 0!==window.ga){for(var e=arguments.length,t=Array(e...
function c (line 21) | function c(e,t){var n=t.currentRoute,r=e?e(t.currentRoute):t;k(n.name)||...
function l (line 21) | function l(e){if(w.autoTracking.page&&e){var t=w.autoTracking.pageviewTe...
function _ (line 21) | function _(e){i("send","exception",{exDescription:e,exFatal:arguments.le...
function f (line 21) | function f(){w.autoTracking.exception&&(window.onerror=function(e){retur...
function m (line 21) | function m(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=argu...
function h (line 21) | function h(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=argu...
function p (line 21) | function p(){i.apply(void 0,arguments)}
function y (line 21) | function y(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=argu...
function v (line 21) | function v(e){i("require",e)}
function M (line 21) | function M(r,a){if(!w.manual){if(!w.id||!w.id.length){return void Y("Ple...
function g (line 21) | function g(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[...
function n (line 21) | function n(e,t){for(var n in t)e.setAttribute(n,t[n])}
function r (line 21) | function r(e,t){e.onload=function(){this.onerror=this.onload=null,t(null...
function a (line 21) | function a(e,t){e.onreadystatechange=function(){"complete"!=this.readySt...
function t (line 21) | function t(r){if(n[r])return n[r].exports;var a=n[r]={i:r,l:!1,exports:{...
function r (line 21) | function r(e){return"object"===s()(window.HTMLElement)?e instanceof wind...
function r (line 21) | function r(e){return e&&e.__esModule?e:{default:e}}
function n (line 21) | function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a ...
function e (line 21) | function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.en...
function e (line 21) | function e(t){n(this,e),this.resolveOptions(t),this.initSelection()}
function a (line 21) | function a(e){return e&&e.__esModule?e:{default:e}}
function i (line 21) | function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a ...
function o (line 21) | function o(e,t){if(!e)throw new ReferenceError("this hasn't been initial...
function s (line 21) | function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("S...
function u (line 21) | function u(e,t){var n="data-clipboard-"+e;if(t.hasAttribute(n))return t....
function e (line 21) | function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.en...
function t (line 21) | function t(e,n){i(this,t);var r=o(this,(t.__proto__||Object.getPrototype...
function n (line 21) | function n(e,t){for(;e&&e.nodeType!==r;){if("function"==typeof e.matches...
function r (line 21) | function r(e,t,n,r,i){var o=a.apply(this,arguments);return e.addEventLis...
function a (line 21) | function a(e,t,n,r){return function(n){n.delegateTarget=i(n.target,t),n....
function r (line 21) | function r(e,t,n){if(!e&&!t&&!n)throw new Error("Missing required argume...
function a (line 21) | function a(e,t,n){return e.addEventListener(t,n),{destroy:function(){e.r...
function i (line 21) | function i(e,t,n){return Array.prototype.forEach.call(e,function(e){e.ad...
function o (line 21) | function o(e,t,n){return u(document.body,e,t,n)}
function n (line 21) | function n(e){var t;if("SELECT"===e.nodeName)e.focus(),t=e.value;else if...
function n (line 21) | function n(){}
function r (line 21) | function r(){a.off(e,r),t.apply(n,arguments)}
function n (line 31) | function n(t){void 0===t&&(t={});var n=t.key;void 0===n&&(n="vuex");var ...
function t (line 31) | function t(e,t){var n=e.split("_");return t%10==1&&t%100!=11?n[0]:t%10>=...
function n (line 31) | function n(e,n,r){var a={mm:n?"хвіліна_хвіліны_хвілін":"хвіліну_хвіліны_...
function t (line 31) | function t(e,t,n){return e+" "+a({mm:"munutenn",MM:"miz",dd:"devezh"}[n]...
function n (line 31) | function n(e){switch(r(e)){case 1:case 3:case 4:case 5:case 9:return e+"...
function r (line 31) | function r(e){return e>9?r(e%10):e}
function a (line 31) | function a(e,t){return 2===t?i(e):e}
function i (line 31) | function i(e){var t={m:"v",b:"v",d:"z"};return void 0===t[e.charAt(0)]?e...
function t (line 31) | function t(e,t,n){var r=e+" ";switch(n){case"m":return t?"jedna minuta":...
function t (line 31) | function t(e){return e>1&&e<5&&1!=~~(e/10)}
function n (line 31) | function n(e,n,r,a){var i=e+" ";switch(r){case"s":return n||a?"pár sekun...
function t (line 31) | function t(e,t,n,r){var a={m:["eine Minute","einer Minute"],h:["eine Stu...
function t (line 31) | function t(e,t,n,r){var a={m:["eine Minute","einer Minute"],h:["eine Stu...
function t (line 31) | function t(e,t,n,r){var a={m:["eine Minute","einer Minute"],h:["eine Stu...
function t (line 31) | function t(e){return e instanceof Function||"[object Function]"===Object...
function t (line 31) | function t(e,t,n,r){var a={s:["mõne sekundi","mõni sekund","paar sekundi...
function t (line 31) | function t(e,t,r,a){var i="";switch(r){case"s":return a?"muutaman sekunn...
function n (line 31) | function n(e,t){return e<10?t?a[e]:r[e]:e}
function t (line 31) | function t(e,t,n,r){var a={s:["thodde secondanim","thodde second"],m:["e...
function t (line 31) | function t(e,t,n){var r=e+" ";switch(n){case"m":return t?"jedna minuta":...
function t (line 31) | function t(e,t,n,r){var a=e;switch(n){case"s":return r||t?"néhány másodp...
function n (line 31) | function n(e){return(e?"":"[múlt] ")+"["+r[this.day()]+"] LT[-kor]"}
function t (line 31) | function t(e){return e%100==11||e%10!=1}
function n (line 31) | function n(e,n,r,a){var i=e+" ";switch(r){case"s":return n||a?"nokkrar s...
function t (line 31) | function t(e,t,n,r){var a={m:["eng Minutt","enger Minutt"],h:["eng Stonn...
function n (line 31) | function n(e){return a(e.substr(0,e.indexOf(" ")))?"a "+e:"an "+e}
function r (line 31) | function r(e){return a(e.substr(0,e.indexOf(" ")))?"viru "+e:"virun "+e}
function a (line 31) | function a(e){if(e=parseInt(e,10),isNaN(e))return!1;if(e<0)return!0;if(e...
function t (line 31) | function t(e,t,n,r){return t?"kelios sekundės":r?"kelių sekundžių":"keli...
function n (line 31) | function n(e,t,n,r){return t?a(n)[0]:r?a(n)[1]:a(n)[2]}
function r (line 31) | function r(e){return e%10==0||e>10&&e<20}
function a (line 31) | function a(e){return o[e].split("_")}
function i (line 31) | function i(e,t,i,o){var s=e+" ";return 1===e?s+n(e,t,i[0],o):t?s+(r(e)?a...
function t (line 31) | function t(e,t,n){return n?t%10==1&&t%100!=11?e[2]:e[3]:t%10==1&&t%100!=...
function n (line 31) | function n(e,n,r){return e+" "+t(i[r],e,n)}
function r (line 31) | function r(e,n,r){return t(i[r],e,n)}
function a (line 31) | function a(e,t){return t?"dažas sekundes":"dažām sekundēm"}
function t (line 31) | function t(e,t,n,r){var a="";if(t)switch(n){case"s":a="काही सेकंद";break...
function t (line 31) | function t(e){return e%10<5&&e%10>1&&~~(e/10)%10!=1}
function n (line 31) | function n(e,n,r){var a=e+" ";switch(r){case"m":return n?"minuta":"minut...
function t (line 31) | function t(e,t,n){var r={mm:"minute",hh:"ore",dd:"zile",MM:"luni",yy:"an...
function t (line 31) | function t(e,t){var n=e.split("_");return t%10==1&&t%100!=11?n[0]:t%10>=...
function n (line 31) | function n(e,n,r){var a={mm:n?"минута_минуты_минут":"минуту_минуты_минут...
function t (line 31) | function t(e){return e>1&&e<5}
function n (line 31) | function n(e,n,r,a){var i=e+" ";switch(r){case"s":return n||a?"pár sekún...
function t (line 31) | function t(e,t,n,r){var a=e+" ";switch(n){case"s":return t||r?"nekaj sek...
function t (line 31) | function t(e){var t=e;return t=-1!==e.indexOf("jaj")?t.slice(0,-3)+"leS"...
function n (line 31) | function n(e){var t=e;return t=-1!==e.indexOf("jaj")?t.slice(0,-3)+"Hu’"...
function r (line 31) | function r(e,t,n,r){var i=a(e);switch(n){case"mm":return i+" tup";case"h...
function a (line 31) | function a(e){var t=Math.floor(e%1e3/100),n=Math.floor(e%100/10),r=e%10,...
function t (line 31) | function t(e,t,n,r){var a={s:["viensas secunds","'iensas secunds"],m:["'...
function t (line 31) | function t(e,t){var n=e.split("_");return t%10==1&&t%100!=11?n[0]:t%10>=...
function n (line 31) | function n(e,n,r){var a={mm:n?"хвилина_хвилини_хвилин":"хвилину_хвилини_...
function r (line 31) | function r(e,t){var n={nominative:"неділя_понеділок_вівторок_середа_четв...
function a (line 31) | function a(e){return function(){return e+"о"+(11===this.hours()?"б":"")+...
function r (line 31) | function r(e){var t=this;e=a(t,e);var n=i(t,e);return f(t,n,e),m(n,e),t....
function a (line 31) | function a(e,t){var n={constructor:"function"==typeof t?t:null,invokePar...
function i (line 31) | function i(e,t){var n=o(e,t);return n.prototype=s(e,n,t),Object.assign(n...
function o (line 31) | function o(e,t){var n;return n=function(e){if(!(this instanceof n))retur...
function s (line 31) | function s(e,t,n){var r=Object.create(e.prototype);return n.methods&&Obj...
function u (line 31) | function u(e){var t={};return e.forEach(function(e){"string"==typeof e?t...
function d (line 31) | function d(e,t,n,r){var a=e;"string"==typeof r&&r.split(".").forEach(fun...
function r (line 31) | function r(e){return e&&(e.fn&&"function"==typeof e.fn||e.constant||e.re...
function r (line 31) | function r(e){if(u)try{var t=c(e);return this.register.constant(e,t),thi...
function a (line 31) | function a(e,t,n){n&&"object"==typeof n||(n={});var r=0;return e&&t&&e.f...
function i (line 31) | function i(e,t,n){t&&!Array.isArray(t)&&(t=Array.prototype.slice.call(t)...
function o (line 31) | function o(e,t){return Array.isArray(e)?_.resolveDependencies(this,{depe...
function s (line 31) | function s(e){e=e?[].concat(e):[];var t;for(t in this.$$factories)(!e.le...
function o (line 31) | function o(){var e=Array.prototype.slice.call(arguments);return e.unshif...
function a (line 31) | function a(){var e=Array.prototype.slice.call(arguments),a={},i=1;return...
function t (line 31) | function t(e,t,n){Object.defineProperty(e,t,{enumerable:!0,configurable:...
function n (line 31) | function n(e,n,i){e&&[].concat(e).forEach(function(e){switch(a(e)){case"...
function r (line 31) | function r(){}
function a (line 31) | function a(e,t){return function(){e.apply(t,arguments)}}
function i (line 31) | function i(e){if("object"!=typeof this)throw new TypeError("Promises mus...
function o (line 31) | function o(e,t){for(;3===e._state;)e=e._value;if(0===e._state)return voi...
function s (line 31) | function s(e,t){try{if(t===e)throw new TypeError("A promise cannot be re...
function u (line 31) | function u(e,t){e._state=2,e._value=t,d(e)}
function d (line 31) | function d(e){2===e._state&&0===e._deferreds.length&&i._immediateFn(func...
function c (line 31) | function c(e,t,n){this.onFulfilled="function"==typeof e?e:null,this.onRe...
function l (line 31) | function l(e,t){var n=!1;try{e(function(e){n||(n=!0,s(t,e))},function(e)...
function r (line 31) | function r(i,o){try{if(o&&("object"==typeof o||"function"==typeof o)){va...
function r (line 31) | function r(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new...
function a (line 31) | function a(e){delete d[e]}
function i (line 31) | function i(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();brea...
function o (line 31) | function o(e){if(c)setTimeout(o,0,e);else{var t=d[e];if(t){c=!0;try{i(t)...
function n (line 31) | function n(){throw new Error("setTimeout has not been defined")}
function r (line 31) | function r(){throw new Error("clearTimeout has not been defined")}
function a (line 31) | function a(e){if(c===setTimeout)return setTimeout(e,0);if((c===n||!c)&&s...
function i (line 31) | function i(e){if(l===clearTimeout)return clearTimeout(e);if((l===r||!l)&...
function o (line 31) | function o(){h&&f&&(h=!1,f.length?m=f.concat(m):p=-1,m.length&&s())}
function s (line 31) | function s(){if(!h){var e=a(o);h=!0;for(var t=m.length;t;){for(f=m,m=[];...
function u (line 31) | function u(e,t){this.fun=e,this.array=t}
function d (line 31) | function d(){}
function e (line 31) | function e(e,t){return setTimeout(e,t)}
function e (line 31) | function e(e,t){return setInterval(e,t)}
function r (line 31) | function r(n){return a?t(n):e(n,0)}
function r (line 31) | function r(e,t){return e.set(t[0],t[1]),e}
function a (line 31) | function a(e,t){return e.add(t),e}
function i (line 31) | function i(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return...
function o (line 31) | function o(e,t){for(var n=-1,r=e?e.length:0;++n<r&&!1!==t(e[n],n,e););re...
function s (line 31) | function s(e,t){for(var n=-1,r=t.length,a=e.length;++n<r;)e[a+n]=t[n];re...
function u (line 31) | function u(e,t,n,r){var a=-1,i=e?e.length:0;for(r&&i&&(n=e[++a]);++a<i;)...
function d (line 31) | function d(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}
function c (line 31) | function c(e,t){return null==e?void 0:e[t]}
function l (line 31) | function l(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!...
function _ (line 31) | function _(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[...
function f (line 31) | function f(e,t){return function(n){return e(t(n))}}
function m (line 31) | function m(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++...
function h (line 31) | function h(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t...
function p (line 31) | function p(){this.__data__=Xt?Xt(null):{}}
function y (line 31) | function y(e){return this.has(e)&&delete this.__data__[e]}
function v (line 31) | function v(e){var t=this.__data__;if(Xt){var n=t[e];return n===Ie?void 0...
function M (line 31) | function M(e){var t=this.__data__;return Xt?void 0!==t[e]:At.call(t,e)}
function g (line 31) | function g(e,t){return this.__data__[e]=Xt&&void 0===t?Ie:t,this}
function L (line 31) | function L(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t...
function Y (line 31) | function Y(){this.__data__=[]}
function k (line 31) | function k(e){var t=this.__data__,n=N(t,e);return!(n<0)&&(n==t.length-1?...
function b (line 31) | function b(e){var t=this.__data__,n=N(t,e);return n<0?void 0:t[n][1]}
function w (line 31) | function w(e){return N(this.__data__,e)>-1}
function D (line 31) | function D(e,t){var n=this.__data__,r=N(n,e);return r<0?n.push([e,t]):n[...
function T (line 31) | function T(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t...
function S (line 31) | function S(){this.__data__={hash:new h,map:new(Bt||L),string:new h}}
function j (line 31) | function j(e){return fe(this,e).delete(e)}
function x (line 31) | function x(e){return fe(this,e).get(e)}
function H (line 31) | function H(e){return fe(this,e).has(e)}
function O (line 31) | function O(e,t){return fe(this,e).set(e,t),this}
function A (line 31) | function A(e){this.__data__=new L(e)}
function E (line 31) | function E(){this.__data__=new L}
function P (line 31) | function P(e){return this.__data__.delete(e)}
function $ (line 31) | function $(e){return this.__data__.get(e)}
function C (line 31) | function C(e){return this.__data__.has(e)}
function F (line 31) | function F(e,t){var n=this.__data__;if(n instanceof L){var r=n.__data__;...
function W (line 31) | function W(e,t){var n=cn(e)||De(e)?d(e.length,String):[],r=n.length,a=!!...
function I (line 31) | function I(e,t,n){(void 0===n||we(e[t],n))&&("number"!=typeof t||void 0!...
function R (line 31) | function R(e,t,n){var r=e[t];At.call(e,t)&&we(r,n)&&(void 0!==n||t in e)...
function N (line 31) | function N(e,t){for(var n=e.length;n--;)if(we(e[n][0],t))return n;return-1}
function z (line 31) | function z(e,t){return e&&ce(t,Pe(t),e)}
function J (line 31) | function J(e,t,n,r,a,i,s){var u;if(r&&(u=i?r(e,a,i,s):r(e)),void 0!==u)r...
function U (line 31) | function U(e){return He(e)?Rt(e):{}}
function V (line 31) | function V(e,t,n){var r=t(e);return cn(e)?r:s(r,n(e))}
function G (line 31) | function G(e){return Pt.call(e)}
function q (line 31) | function q(e){return!(!He(e)||Le(e))&&(je(e)||l(e)?$t:mt).test(be(e))}
function B (line 31) | function B(e){return Oe(e)&&xe(e.length)&&!!pt[Pt.call(e)]}
function K (line 31) | function K(e){if(!Ye(e))return Vt(e);var t=[];for(var n in Object(e))At....
function Z (line 31) | function Z(e){if(!He(e))return ke(e);var t=Ye(e),n=[];for(var r in e)("c...
function Q (line 31) | function Q(e,t,n,r,a){if(e!==t){if(!cn(t)&&!_n(t))var i=Z(t);o(i||t,func...
function X (line 31) | function X(e,t,n,r,a,i,o){var s=e[n],u=t[n],d=o.get(u);if(d)return void ...
function ee (line 31) | function ee(e,t){return t=Gt(void 0===t?e.length-1:t,0),function(){for(v...
function te (line 31) | function te(e,t){if(t)return e.slice();var n=new e.constructor(e.length)...
function ne (line 31) | function ne(e){var t=new e.constructor(e.byteLength);return new Wt(t).se...
function re (line 31) | function re(e,t){var n=t?ne(e.buffer):e.buffer;return new e.constructor(...
function ae (line 31) | function ae(e,t,n){return u(t?n(_(e),!0):_(e),r,new e.constructor)}
function ie (line 31) | function ie(e){var t=new e.constructor(e.source,ft.exec(e));return t.las...
function oe (line 31) | function oe(e,t,n){return u(t?n(m(e),!0):m(e),a,new e.constructor)}
function se (line 31) | function se(e){return sn?Object(sn.call(e)):{}}
function ue (line 31) | function ue(e,t){var n=t?ne(e.buffer):e.buffer;return new e.constructor(...
function de (line 31) | function de(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n...
function ce (line 31) | function ce(e,t,n,r){n||(n={});for(var a=-1,i=t.length;++a<i;){var o=t[a...
function le (line 31) | function le(e,t){return ce(e,un(e),t)}
function _e (line 31) | function _e(e){return V(e,Pe,un)}
function fe (line 31) | function fe(e,t){var n=e.__data__;return ge(t)?n["string"==typeof t?"str...
function me (line 31) | function me(e,t){var n=c(e,t);return q(n)?n:void 0}
function he (line 31) | function he(e){var t=e.length,n=e.constructor(t);return t&&"string"==typ...
function pe (line 31) | function pe(e){return"function"!=typeof e.constructor||Ye(e)?{}:U(It(e))}
function ye (line 31) | function ye(e,t,n,r){var a=e.constructor;switch(t){case tt:return ne(e);...
function ve (line 31) | function ve(e,t){return!!(t=null==t?Re:t)&&("number"==typeof e||ht.test(...
function Me (line 31) | function Me(e,t,n){if(!He(n))return!1;var r=typeof t;return!!("number"==...
function ge (line 31) | function ge(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==...
function Le (line 31) | function Le(e){return!!Ht&&Ht in e}
function Ye (line 31) | function Ye(e){var t=e&&e.constructor;return e===("function"==typeof t&&...
function ke (line 31) | function ke(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);retu...
function be (line 31) | function be(e){if(null!=e){try{return Ot.call(e)}catch(e){}try{return e+...
function we (line 31) | function we(e,t){return e===t||e!==e&&t!==t}
function De (line 31) | function De(e){return Se(e)&&At.call(e,"callee")&&(!Nt.call(e,"callee")|...
function Te (line 31) | function Te(e){return null!=e&&xe(e.length)&&!je(e)}
function Se (line 31) | function Se(e){return Oe(e)&&Te(e)}
function je (line 31) | function je(e){var t=He(e)?Pt.call(e):"";return t==Ue||t==Ve}
function xe (line 31) | function xe(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=Re}
function He (line 31) | function He(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}
function Oe (line 31) | function Oe(e){return!!e&&"object"==typeof e}
function Ae (line 31) | function Ae(e){if(!Oe(e)||Pt.call(e)!=Be||l(e))return!1;var t=It(e);if(n...
function Ee (line 31) | function Ee(e){return ce(e,$e(e))}
function Pe (line 31) | function Pe(e){return Te(e)?W(e):K(e)}
function $e (line 31) | function $e(e){return Te(e)?W(e,!0):Z(e)}
function Ce (line 31) | function Ce(){return[]}
function Fe (line 31) | function Fe(){return!1}
function e (line 31) | function e(e,t){return null!=e&&Object.prototype.hasOwnProperty.call(e,t)}
function t (line 31) | function t(t){if(!t)return!0;if(u(t)&&0===t.length)return!0;if("string"!...
function n (line 31) | function n(e){return s.call(e)}
function r (line 31) | function r(e){return"object"==typeof e&&"[object Object]"===n(e)}
function a (line 31) | function a(e){return"boolean"==typeof e||"[object Boolean]"===n(e)}
function i (line 31) | function i(e){var t=parseInt(e);return t.toString()===e?t:e}
function o (line 31) | function o(n){function o(t,r){return n.includeInheritedProps||"number"==...
function r (line 31) | function r(e){return n(a(e))}
function a (line 31) | function a(e){var t=i[e];if(!(t+1))throw new Error("Cannot find module '...
FILE: test/testUtilities.ts
function getWorkspaceFile (line 5) | function getWorkspaceFile(pathFromWorkspace: string): string {
function resolve (line 10) | function resolve(...paths: string[]): string {
function join (line 15) | function join(...paths: string[]): string {
Condensed preview — 137 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (932K chars).
[
{
"path": ".appveyor.yml",
"chars": 323,
"preview": "version: \"{build} - {branch}\"\nskip_tags: true\nskip_branch_with_pr: true\n\nmatrix:\n fast_finish: true\n\nenvironment:\n mat"
},
{
"path": ".gitignore",
"chars": 89,
"preview": "# node\nlogs\n*.log\nnpm-debug.log*\nnode_modules/\n\n# testing\ncoverage/\n\n# typescript\nbuild/\n"
},
{
"path": ".npmignore",
"chars": 170,
"preview": "# node\nlogs\n*.log\nnpm-debug.log*\nnode_modules/\n\n# testing\ncoverage/\ntest/\n\n# typescript\nsrc/\nbuild/\ntsconfig.json\nconfig"
},
{
"path": ".npmrc",
"chars": 19,
"preview": "package-lock=false\n"
},
{
"path": ".travis.yml",
"chars": 774,
"preview": "language: node_js\n\nstages:\n - name: test\n if: tag IS blank\n - name: build\n if: tag IS blank\n - name: deploy\n "
},
{
"path": "LICENSE",
"chars": 1074,
"preview": "MIT License\n\nCopyright (c) 2017 TypeScript Heroes\n\nPermission is hereby granted, free of charge, to any person obtaining"
},
{
"path": "README.md",
"chars": 2319,
"preview": "# node typescript parser\n\nThis package is a TypeScript and ECMAScript parser. It uses the underlying typescript parser t"
},
{
"path": "config/tsconfig.base.json",
"chars": 660,
"preview": "{\n \"compilerOptions\": {\n \"target\": \"es6\",\n \"module\": \"commonjs\",\n \"moduleResolution\": \"node\",\n "
},
{
"path": "config/tsconfig.build.json",
"chars": 98,
"preview": "{\n \"extends\": \"./tsconfig.base.json\",\n \"compilerOptions\": {\n \"outDir\": \"../\"\n }\n}\n"
},
{
"path": "jest.json",
"chars": 405,
"preview": "{\n \"collectCoverage\": true,\n \"transform\": {\n \"^.+\\\\.tsx?$\": \"<rootDir>/node_modules/ts-jest/preprocessor.js"
},
{
"path": "package.json",
"chars": 1840,
"preview": "{\n \"name\": \"typescript-parser\",\n \"version\": \"0.0.0-development\",\n \"description\": \"Parser for typescript (and javascri"
},
{
"path": "src/DeclarationIndex.ts",
"chars": 18686,
"preview": "import { difference, differenceWith, intersection, isEqual } from 'lodash';\nimport { join, normalize, relative, resolve "
},
{
"path": "src/Node.ts",
"chars": 480,
"preview": "/**\n * Base class for all nodes / declarations / imports / etc. in the extension.\n * Contains basic information about th"
},
{
"path": "src/SymbolSpecifier.ts",
"chars": 713,
"preview": "import { Clonable } from './clonable/Clonable';\n\n/**\n * Class for symbols that are contained in a named import or export"
},
{
"path": "src/TypescriptParser.ts",
"chars": 7941,
"preview": "import { readFileSync } from 'fs';\nimport { parse } from 'path';\nimport {\n ClassDeclaration,\n createSourceFile,\n "
},
{
"path": "src/clonable/Clonable.ts",
"chars": 318,
"preview": "/**\n * Interface for clonable objects. The clone() method creates a deep clone of the object.\n *\n * @export\n * @template"
},
{
"path": "src/code-generators/TypescriptCodeGenerator.ts",
"chars": 3777,
"preview": "import { GetterDeclaration, SetterDeclaration } from '../declarations/AccessorDeclaration';\nimport { Declaration } from "
},
{
"path": "src/code-generators/TypescriptGenerationOptions.ts",
"chars": 1915,
"preview": "export enum MultiLineImportRule {\n strictlyOneImportPerLine = 'strictlyOneImportPerLine',\n oneImportPerLineOnlyAft"
},
{
"path": "src/code-generators/typescript-generators/accessorDeclaration.ts",
"chars": 1448,
"preview": "import { AccessorDeclaration, SetterDeclaration } from '../../declarations/AccessorDeclaration';\nimport { getVisibilityT"
},
{
"path": "src/code-generators/typescript-generators/externalModuleImport.ts",
"chars": 619,
"preview": "import { ExternalModuleImport } from '../../imports/ExternalModuleImport';\nimport { TypescriptGenerationOptions } from '"
},
{
"path": "src/code-generators/typescript-generators/methodDeclaration.ts",
"chars": 1011,
"preview": "import { getVisibilityText } from '../../declarations/DeclarationVisibility';\nimport { MethodDeclaration } from '../../d"
},
{
"path": "src/code-generators/typescript-generators/namedImport.ts",
"chars": 4850,
"preview": "import { NamedImport } from '../../imports/NamedImport';\nimport { SymbolSpecifier } from '../../SymbolSpecifier';\nimport"
},
{
"path": "src/code-generators/typescript-generators/namespaceImport.ts",
"chars": 585,
"preview": "import { NamespaceImport } from '../../imports/NamespaceImport';\nimport { TypescriptGenerationOptions } from '../Typescr"
},
{
"path": "src/code-generators/typescript-generators/parameterDeclaration.ts",
"chars": 380,
"preview": "import { ParameterDeclaration } from '../../declarations/ParameterDeclaration';\n\n/**\n * Generates typescript code for pa"
},
{
"path": "src/code-generators/typescript-generators/propertyDeclaration.ts",
"chars": 826,
"preview": "import { getVisibilityText } from '../../declarations/DeclarationVisibility';\nimport { PropertyDeclaration } from '../.."
},
{
"path": "src/code-generators/typescript-generators/stringImport.ts",
"chars": 534,
"preview": "import { StringImport } from '../../imports/StringImport';\nimport { TypescriptGenerationOptions } from '../TypescriptGen"
},
{
"path": "src/code-generators/typescript-generators/symbolSpecifier.ts",
"chars": 359,
"preview": "import { SymbolSpecifier } from '../../SymbolSpecifier';\n\n/**\n * Generates typescript code for a symbol specifier.\n *\n *"
},
{
"path": "src/code-generators/typescript-generators/variableDeclaration.ts",
"chars": 370,
"preview": "import { VariableDeclaration } from '../../declarations/VariableDeclaration';\n\n/**\n * Generates typescript code for a va"
},
{
"path": "src/declarations/AccessorDeclaration.ts",
"chars": 1318,
"preview": "import { AbstractDeclaration, ScopedDeclaration, StaticDeclaration, TypedDeclaration } from './Declaration';\nimport { De"
},
{
"path": "src/declarations/ClassDeclaration.ts",
"chars": 1090,
"preview": "import { AccessorDeclaration } from './AccessorDeclaration';\nimport { ConstructorDeclaration } from './ConstructorDeclar"
},
{
"path": "src/declarations/ConstructorDeclaration.ts",
"chars": 617,
"preview": "import { CallableDeclaration } from './Declaration';\nimport { ParameterDeclaration } from './ParameterDeclaration';\nimpo"
},
{
"path": "src/declarations/Declaration.ts",
"chars": 5734,
"preview": "import { Node } from '../Node';\nimport { AccessorDeclaration } from './AccessorDeclaration';\nimport { DeclarationVisibil"
},
{
"path": "src/declarations/DeclarationInfo.ts",
"chars": 319,
"preview": "import { Declaration } from './Declaration';\n\n/**\n * Class that defines information about a declaration.\n * Contains the"
},
{
"path": "src/declarations/DeclarationVisibility.ts",
"chars": 708,
"preview": "/**\n * Returns the visibility string for a given enum value.\n *\n * @param {DeclarationVisibility} [visibility]\n * @retur"
},
{
"path": "src/declarations/DefaultDeclaration.ts",
"chars": 969,
"preview": "import { Resource } from '../resources/Resource';\nimport { Declaration, ExportableDeclaration } from './Declaration';\n\n/"
},
{
"path": "src/declarations/EnumDeclaration.ts",
"chars": 418,
"preview": "import { ExportableDeclaration } from './Declaration';\n\n/**\n * Enum declaration.\n *\n * @export\n * @class EnumDeclaration"
},
{
"path": "src/declarations/FunctionDeclaration.ts",
"chars": 896,
"preview": "import { AsyncDeclaration, CallableDeclaration, ExportableDeclaration } from './Declaration';\nimport { ParameterDeclarat"
},
{
"path": "src/declarations/InterfaceDeclaration.ts",
"chars": 938,
"preview": "import { AccessorDeclaration } from './AccessorDeclaration';\nimport { ClassLikeDeclaration, ExportableDeclaration, Gener"
},
{
"path": "src/declarations/MethodDeclaration.ts",
"chars": 1339,
"preview": "import {\n AbstractDeclaration,\n AsyncDeclaration,\n CallableDeclaration,\n OptionalDeclaration,\n ScopedDecl"
},
{
"path": "src/declarations/ModuleDeclaration.ts",
"chars": 428,
"preview": "import { Declaration } from './Declaration';\n\n/**\n * Module (namespace) declaration. Does export a whole module or names"
},
{
"path": "src/declarations/ParameterDeclaration.ts",
"chars": 1664,
"preview": "import { TypedDeclaration } from './Declaration';\n\n/**\n * Parameter declaration. Is contained in a method or function de"
},
{
"path": "src/declarations/PropertyDeclaration.ts",
"chars": 763,
"preview": "import { OptionalDeclaration, ScopedDeclaration, StaticDeclaration, TypedDeclaration } from './Declaration';\nimport { De"
},
{
"path": "src/declarations/TypeAliasDeclaration.ts",
"chars": 482,
"preview": "import { ExportableDeclaration } from './Declaration';\n\n/**\n * Alias declaration that can be exported. Is used to define"
},
{
"path": "src/declarations/VariableDeclaration.ts",
"chars": 596,
"preview": "import { ExportableDeclaration, TypedDeclaration } from './Declaration';\n\n/**\n * Variable declaration. Is contained in a"
},
{
"path": "src/declarations/index.ts",
"chars": 608,
"preview": "export * from './AccessorDeclaration';\nexport * from './ClassDeclaration';\nexport * from './ConstructorDeclaration';\nexp"
},
{
"path": "src/errors/NotGeneratableYetError.ts",
"chars": 451,
"preview": "import { Generatable } from '../code-generators/TypescriptCodeGenerator';\n\n/**\n * Error that should be thrown, when a ge"
},
{
"path": "src/exports/AllExport.ts",
"chars": 282,
"preview": "import { Export } from './Export';\n\n/**\n * Declares an all export (i.e. export * from ...).\n *\n * @export\n * @class AllE"
},
{
"path": "src/exports/AssignedExport.ts",
"chars": 1445,
"preview": "import { ExportableDeclaration } from '../declarations/Declaration';\nimport { Module } from '../resources/Module';\nimpor"
},
{
"path": "src/exports/Export.ts",
"chars": 196,
"preview": "import { Node } from '../Node';\n\n/**\n * Basic export interface. Defines an export in a document.\n *\n * @export\n * @inter"
},
{
"path": "src/exports/NamedExport.ts",
"chars": 405,
"preview": "import { SymbolSpecifier } from '../SymbolSpecifier';\nimport { Export } from './Export';\n\n/**\n * Declares a named export"
},
{
"path": "src/exports/index.ts",
"chars": 120,
"preview": "export * from './AllExport';\nexport * from './AssignedExport';\nexport * from './Export';\nexport * from './NamedExport';\n"
},
{
"path": "src/imports/ExternalModuleImport.ts",
"chars": 821,
"preview": "import { AliasedImport } from './Import';\n\n/**\n * Alternative to the namespace import. Can be used by various libraries."
},
{
"path": "src/imports/Import.ts",
"chars": 1095,
"preview": "import { Clonable } from '../clonable/Clonable';\nimport { Node } from '../Node';\n\n/**\n * Basic import interface. Defines"
},
{
"path": "src/imports/NamedImport.ts",
"chars": 1103,
"preview": "import { SymbolSpecifier } from '../SymbolSpecifier';\nimport { Import } from './Import';\n\n/**\n * Basic typescript import"
},
{
"path": "src/imports/NamespaceImport.ts",
"chars": 757,
"preview": "import { AliasedImport } from './Import';\n\n/**\n * Import that imports a whole namespace (i.e. import * as foobar from 'f"
},
{
"path": "src/imports/StringImport.ts",
"chars": 658,
"preview": "import { Import } from './Import';\n\n/**\n * Simple string import (i.e. import \"reflect-metadata\";).\n *\n * @export\n * @cla"
},
{
"path": "src/imports/index.ts",
"chars": 164,
"preview": "export * from './ExternalModuleImport';\nexport * from './Import';\nexport * from './NamedImport';\nexport * from './Namesp"
},
{
"path": "src/index.ts",
"chars": 424,
"preview": "export * from './TypescriptParser';\nexport * from './Node';\nexport * from './SymbolSpecifier';\n\nexport * from './Declara"
},
{
"path": "src/node-parser/class-parser.ts",
"chars": 8329,
"preview": "import {\n ArrayBindingPattern,\n ClassDeclaration,\n ConstructorDeclaration,\n Identifier,\n Node,\n Object"
},
{
"path": "src/node-parser/enum-parser.ts",
"chars": 671,
"preview": "import { EnumDeclaration } from 'typescript';\n\nimport { EnumDeclaration as TshEnum } from '../declarations/EnumDeclarati"
},
{
"path": "src/node-parser/export-parser.ts",
"chars": 2888,
"preview": "import { ExportAssignment, ExportDeclaration, Identifier, StringLiteral } from 'typescript';\n\nimport { DefaultDeclaratio"
},
{
"path": "src/node-parser/function-parser.ts",
"chars": 5659,
"preview": "import {\n FunctionDeclaration,\n Identifier,\n isTupleTypeNode,\n isTypeLiteralNode,\n isTypeReferenceNode,\n "
},
{
"path": "src/node-parser/identifier-parser.ts",
"chars": 2548,
"preview": "import { Identifier, Node, SyntaxKind } from 'typescript';\n\nimport { Resource } from '../resources/Resource';\n\nconst usa"
},
{
"path": "src/node-parser/import-parser.ts",
"chars": 3154,
"preview": "import {\n ExternalModuleReference,\n Identifier,\n ImportDeclaration,\n ImportEqualsDeclaration,\n NamedImpor"
},
{
"path": "src/node-parser/index.ts",
"chars": 372,
"preview": "// export * from './class-parser';\n// export * from './enum-parser';\n// export * from './export-parser';\n// export * fro"
},
{
"path": "src/node-parser/interface-parser.ts",
"chars": 2977,
"preview": "import { Identifier, InterfaceDeclaration, SyntaxKind } from 'typescript';\n\nimport { DeclarationVisibility } from '../de"
},
{
"path": "src/node-parser/module-parser.ts",
"chars": 876,
"preview": "import { Identifier, ModuleDeclaration, NodeFlags } from 'typescript';\n\nimport { Module } from '../resources/Module';\nim"
},
{
"path": "src/node-parser/parse-utilities.ts",
"chars": 2795,
"preview": "import { Declaration, getCombinedModifierFlags, ModifierFlags, Node, SyntaxKind, TypeNode } from 'typescript';\n\nimport {"
},
{
"path": "src/node-parser/traverse-ast.ts",
"chars": 403,
"preview": "export function traverseAst(root: Node, visit: (node: Node) => void, skipContents?: (node: Node) => boolean): void {\n "
},
{
"path": "src/node-parser/type-alias-parser.ts",
"chars": 597,
"preview": "import { TypeAliasDeclaration } from 'typescript';\n\nimport { TypeAliasDeclaration as TshType } from '../declarations/Typ"
},
{
"path": "src/node-parser/variable-parser.ts",
"chars": 1405,
"preview": "import { SyntaxKind, VariableStatement } from 'typescript';\n\nimport { CallableDeclaration } from '../declarations/Declar"
},
{
"path": "src/resources/File.ts",
"chars": 1983,
"preview": "import { parse, ParsedPath, relative } from 'path';\n\nimport { Declaration } from '../declarations/Declaration';\nimport {"
},
{
"path": "src/resources/Module.ts",
"chars": 1817,
"preview": "import { Declaration } from '../declarations/Declaration';\nimport { Export } from '../exports/Export';\nimport { Import }"
},
{
"path": "src/resources/Namespace.ts",
"chars": 1814,
"preview": "import { Declaration } from '../declarations/Declaration';\nimport { Export } from '../exports/Export';\nimport { Import }"
},
{
"path": "src/resources/Resource.ts",
"chars": 1698,
"preview": "import { Declaration } from '../declarations/Declaration';\nimport { Export } from '../exports/Export';\nimport { Import }"
},
{
"path": "src/resources/index.ts",
"chars": 107,
"preview": "export * from './File';\nexport * from './Module';\nexport * from './Namespace';\nexport * from './Resource';\n"
},
{
"path": "src/type-guards/TypescriptGuards.ts",
"chars": 6283,
"preview": "import {\n ArrayBindingPattern,\n ConstructorDeclaration,\n ExportDeclaration,\n ExternalModuleReference,\n Fu"
},
{
"path": "src/type-guards/TypescriptHeroGuards.ts",
"chars": 965,
"preview": "import { CallableDeclaration, ExportableDeclaration } from '../declarations/Declaration';\nimport { AliasedImport } from "
},
{
"path": "src/utilities/PathHelpers.ts",
"chars": 1082,
"preview": "import { platform } from 'os';\n\n/**\n * Returns a normalized version of the a path uri. Removes a \"file://\" or \"file:///\""
},
{
"path": "src/utilities/StringTemplate.ts",
"chars": 570,
"preview": "/**\n * Creates a template from an expression string. The template can then be used to infuse stuff into the template.\n *"
},
{
"path": "test/SpecificUsageCases.spec.ts",
"chars": 1711,
"preview": "import { TypescriptParser } from '../src';\nimport { getWorkspaceFile, rootPath } from './testUtilities';\n\ndescribe('Spec"
},
{
"path": "test/TypescriptParser.spec.ts",
"chars": 33422,
"preview": "import { readFileSync } from 'fs';\nimport { ScriptKind } from 'typescript';\n\nimport { ClassDeclaration } from '../src/de"
},
{
"path": "test/__snapshots__/SpecificUsageCases.spec.ts.snap",
"chars": 1501,
"preview": "// Jest Snapshot v1, https://goo.gl/fbAQLP\n\nexports[`Specific usage cases get usage for directly reexported elements sho"
},
{
"path": "test/__snapshots__/TypescriptParser.spec.ts.snap",
"chars": 67465,
"preview": "// Jest Snapshot v1, https://goo.gl/fbAQLP\n\nexports[`TypescriptParser Declaration parsing Classes should parse a non exp"
},
{
"path": "test/_workspace/.gitignore",
"chars": 15,
"preview": "!node_modules/\n"
},
{
"path": "test/_workspace/declaration-index/_index.ts",
"chars": 19,
"preview": "export let _index;\n"
},
{
"path": "test/_workspace/declaration-index/another-classes.ts",
"chars": 24,
"preview": "export class Class1 { }\n"
},
{
"path": "test/_workspace/declaration-index/circular-export/circularExport1.ts",
"chars": 77,
"preview": "export class ExportedCircularClass1 {\n\n}\n\nexport * from './circularExport2';\n"
},
{
"path": "test/_workspace/declaration-index/circular-export/circularExport2.ts",
"chars": 77,
"preview": "export class ExportedCircularClass2 {\n\n}\n\nexport * from './circularExport1';\n"
},
{
"path": "test/_workspace/declaration-index/classes.ts",
"chars": 357,
"preview": "export class MyClass {\n public doSomething(): void { }\n}\n\nexport class FancierLibraryClass {\n public doSomethingAw"
},
{
"path": "test/_workspace/declaration-index/exports/classes.ts",
"chars": 216,
"preview": "export class Class1 { }\nexport class Class2 { }\nexport class Class3 { }\nexport class Class4 { }\nexport class Class5 { }\n"
},
{
"path": "test/_workspace/declaration-index/exports/export-alias.ts",
"chars": 58,
"preview": "export { Class1 as Foo, Class5 as Bar } from './classes';\n"
},
{
"path": "test/_workspace/declaration-index/exports/export-all.ts",
"chars": 27,
"preview": "export * from './classes';\n"
},
{
"path": "test/_workspace/declaration-index/exports/export-from-export.ts",
"chars": 31,
"preview": "export * from './export-some';\n"
},
{
"path": "test/_workspace/declaration-index/exports/export-some.ts",
"chars": 44,
"preview": "export { Class1, Class5 } from './classes';\n"
},
{
"path": "test/_workspace/declaration-index/helper-functions.ts",
"chars": 187,
"preview": "export function isString(str: any): str is string {\n return str.constructor === String;\n}\n\nexport function isNumber(s"
},
{
"path": "test/_workspace/declaration-index/index.ts",
"chars": 25,
"preview": "export let barrelExport;\n"
},
{
"path": "test/_workspace/declaration-index/myReactTemplate.tsx",
"chars": 125,
"preview": "import * as React from \"react\";\n\nexport const myComponent = (test: string) => {\n return <div>Hello World: {test}</div"
},
{
"path": "test/_workspace/declaration-index/prototype-funcs.ts",
"chars": 119,
"preview": "export function toString(): string {\n return '';\n}\n\nexport function hasOwnProperty(): boolean {\n return false;\n}\n"
},
{
"path": "test/_workspace/declaration-index/reactFile.tsx",
"chars": 143,
"preview": "import { myComponent } from './myReactTemplate';\n\nexport default function foobar() {\n return (\n <myComponent><"
},
{
"path": "test/_workspace/declaration-index/specific-cases/reindex-with-global-module-export/classes.ts",
"chars": 62,
"preview": "\nexport class MyClass { \n public doSomething(): void { }\n}\n"
},
{
"path": "test/_workspace/specific-usage-cases/i18next-destructure/destructure-my-component.tsx",
"chars": 122,
"preview": "import * as React from 'react';\nimport { t } from 'i18next';\n\nexport const MyComponent = () => (\n <p>{t('foo')}</p>\n)"
},
{
"path": "test/_workspace/specific-usage-cases/i18next-destructure/import-my-component.tsx",
"chars": 129,
"preview": "import * as i18next from 'i18next';\nimport * as React from 'react';\n\nexport const MyComponent = () => <p>{i18next.t('foo"
},
{
"path": "test/_workspace/specific-usage-cases/reexport/reexport-default.ts",
"chars": 49,
"preview": "import Test from './Test';\n\nexport default Test;\n"
},
{
"path": "test/_workspace/specific-usage-cases/reexport/reexport-import.ts",
"chars": 185,
"preview": "import * as colors from './colors';\nimport * as helpers from './helpers';\nimport * as icons from './icons';\nimport * as "
},
{
"path": "test/_workspace/typescript-parser/async.ts",
"chars": 336,
"preview": "class Class1 {\n public static async staticAsync() { }\n public func(): void { }\n public async asyncFunc(): Promi"
},
{
"path": "test/_workspace/typescript-parser/class.ts",
"chars": 1663,
"preview": "abstract class AbstractClass {\n public method1() { }\n\n public abstract abstractMethod(): void;\n}\n\nclass NonExporte"
},
{
"path": "test/_workspace/typescript-parser/enum.ts",
"chars": 137,
"preview": "enum Enumeration {\n Member1,\n Member2,\n Member3\n}\n\nexport const enum ConstantEnumeration {\n ConstMember1,\n "
},
{
"path": "test/_workspace/typescript-parser/exportsOnly.ts",
"chars": 139,
"preview": "export * from './OtherFile';\n\nexport {Specifier, Specifier as Alias} from './AnotherFile';\n\nexport = Foo;\n\nexport defaul"
},
{
"path": "test/_workspace/typescript-parser/function.ts",
"chars": 357,
"preview": "function function1(param1): string {\n let var1 = 'foobar';\n return 'foobar';\n}\n\nexport function function2(param1: "
},
{
"path": "test/_workspace/typescript-parser/importsOnly.ts",
"chars": 662,
"preview": "import 'stringImport';\nimport { Specifier1, Specifier2, Specifier3 } from 'namedImport';\nimport { Specifier1 as Alias1 }"
},
{
"path": "test/_workspace/typescript-parser/interface.ts",
"chars": 715,
"preview": "interface NonExportedInterface {\n property1: string;\n property2: number;\n method1();\n method2(param1: string"
},
{
"path": "test/_workspace/typescript-parser/javascript.js",
"chars": 122,
"preview": "import $ from 'jquery';\n\nexport class ES6Class {\n constructor() { }\n\n doSomething() { }\n}\n\nexport default ES6Class"
},
{
"path": "test/_workspace/typescript-parser/jsx.jsx",
"chars": 333,
"preview": "import React from 'react';\nimport $ from 'jquery';\n\nexport class ES6Class {\n render() {\n return (\n "
},
{
"path": "test/_workspace/typescript-parser/module.ts",
"chars": 191,
"preview": "declare module 'Module' {\n export function modFunc(): void;\n}\n\ndeclare namespace Namespace {\n class NotExported { "
},
{
"path": "test/_workspace/typescript-parser/parameters.ts",
"chars": 655,
"preview": "function normal(p1: string): void { }\n\nfunction arrBound1([p1, p2]): void { }\n\nfunction arrBound2([p1, p2]: [string, Typ"
},
{
"path": "test/_workspace/typescript-parser/specific-cases/1.tsx",
"chars": 32051,
"preview": "import Divider from 'material-ui/Divider';\nimport { sortBy, cloneDeep, startCase } from 'lodash';\nimport Checkbox from '"
},
{
"path": "test/_workspace/typescript-parser/specific-cases/2.tsx",
"chars": 24898,
"preview": "class EncounterPlanner extends React.Component<Props, State> {\n private static defaultState: State = {\n encoun"
},
{
"path": "test/_workspace/typescript-parser/specific-cases/3.tsx",
"chars": 6290,
"preview": "class CharacterOverview extends React.Component<Props, State>{\n public render(): JSX.Element {\n const chars = "
},
{
"path": "test/_workspace/typescript-parser/typeAlias.ts",
"chars": 50,
"preview": "type Alias = {};\n\nexport type ExportedAlias = {};\n"
},
{
"path": "test/_workspace/typescript-parser/usagesOnly.ts",
"chars": 827,
"preview": "@ClassDecorator\nclass Class {\n @PropertyDecorator()\n public notInitializedProperty;\n\n public typedProperty: Typ"
},
{
"path": "test/_workspace/typescript-parser/usagesOnly.tsx",
"chars": 435,
"preview": "export default function foobar() {\n return (\n <myComponent>\n <div>\n <complexComp>\n "
},
{
"path": "test/_workspace/typescript-parser/variable.ts",
"chars": 207,
"preview": "var NonExportedVariable = '';\n\nconst NonExportedConst = '';\n\nexport var ExportedVariable = '';\n\nexport const ExportedCon"
},
{
"path": "test/_workspace/typescript-parser/webpack-bundle.js",
"chars": 435566,
"preview": "!function(e){function t(n){if(r[n])return r[n].exports;var a=r[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.e"
},
{
"path": "test/code-generators/TypescriptCodeGenerator.spec.ts",
"chars": 9329,
"preview": "import { TypescriptCodeGenerator } from '../../src/code-generators/TypescriptCodeGenerator';\nimport { TypescriptGenerati"
},
{
"path": "test/code-generators/__snapshots__/TypescriptCodeGenerator.spec.ts.snap",
"chars": 16538,
"preview": "// Jest Snapshot v1, https://goo.gl/fbAQLP\n\nexports[`TypescriptCodeGenerator should generate multiple imports per line f"
},
{
"path": "test/declaration-index/DeclarationIndex.spec.ts",
"chars": 17237,
"preview": "import mockFs = require('mock-fs');\nimport { join, resolve } from '../testUtilities';\n\nimport { DeclarationIndex } from "
},
{
"path": "test/declaration-index/__snapshots__/DeclarationIndex.spec.ts.snap",
"chars": 56344,
"preview": "// Jest Snapshot v1, https://goo.gl/fbAQLP\n\nexports[`DeclarationIndex buildIndex() should contain a declaration from a *"
},
{
"path": "test/declaration-index/specific-cases/reindex-with-global-module/DeclarationIndex.reindex-with-global-module-export.spec.ts",
"chars": 1401,
"preview": "import { FileChanges } from '../../../../src';\nimport { join, resolve } from '../../../testUtilities';\n\nimport { Declara"
},
{
"path": "test/declaration-index/specific-cases/reindex-with-global-module/__snapshots__/DeclarationIndex.reindex-with-global-module-export.spec.ts.snap",
"chars": 1483,
"preview": "// Jest Snapshot v1, https://goo.gl/fbAQLP\n\nexports[`DeclarationIndex - specific case \"reindex-with-global-module\" shoul"
},
{
"path": "test/imports/Imports.spec.ts",
"chars": 2634,
"preview": "import { ExternalModuleImport, NamedImport, NamespaceImport, StringImport } from '../../src/imports';\n\ndescribe('Imports"
},
{
"path": "test/parsing/Flags.spec.ts",
"chars": 908,
"preview": "import { FunctionDeclaration, TypescriptParser } from '../../src';\nimport { Resource } from '../../src/resources';\nimpor"
},
{
"path": "test/parsing/__snapshots__/Flags.spec.ts.snap",
"chars": 2505,
"preview": "// Jest Snapshot v1, https://goo.gl/fbAQLP\n\nexports[`TypescriptParser isAsync Flag should parse async functions correctl"
},
{
"path": "test/testUtilities.ts",
"chars": 650,
"preview": "import * as Path from 'path';\n\nimport { toPosix } from '../src/utilities/PathHelpers';\n\nexport function getWorkspaceFile"
},
{
"path": "test/utilities/PathHelpers.spec.ts",
"chars": 1388,
"preview": "import * as os from 'os';\n\nimport { normalizeFilename, normalizePathUri } from '../../src/utilities/PathHelpers';\n\ndescr"
},
{
"path": "tsconfig.json",
"chars": 130,
"preview": "{\n \"extends\": \"./config/tsconfig.base.json\",\n \"compilerOptions\": {\n \"watch\": true,\n \"sourceMap\": tru"
},
{
"path": "tslint.json",
"chars": 210,
"preview": "{\n \"extends\": [\n \"@smartive/tslint-config\"\n ],\n \"rules\": {\n \"ter-indent\": [\n true,\n "
}
]
About this extraction
This page contains the full source code of the buehler/node-typescript-parser GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 137 files (831.0 KB), approximately 258.9k tokens, and a symbol index with 1287 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.