react-docgen-typescript
Advanced tools
Comparing version
@@ -226,9 +226,42 @@ "use strict"; | ||
}); | ||
it('should parse react stateless component with default props', function () { | ||
testUtils_1.check('StatelessWithDefaultProps', { | ||
describe('stateless component with default props', function () { | ||
var expectation = { | ||
StatelessWithDefaultProps: { | ||
sampleJSDoc: { type: 'string', required: false, defaultValue: 'test' }, | ||
sampleProp: { type: 'string', required: false, defaultValue: 'test' } | ||
sampleDefaultFromJSDoc: { | ||
defaultValue: 'hello', | ||
description: 'sample with default value', | ||
required: true, | ||
type: '"hello" | "goodbye"' | ||
}, | ||
sampleFalse: { | ||
defaultValue: 'false', | ||
required: false, | ||
type: 'boolean' | ||
}, | ||
sampleNull: { type: 'null', required: false, defaultValue: 'null' }, | ||
sampleNumber: { type: 'number', required: false, defaultValue: '-1' }, | ||
sampleObject: { | ||
defaultValue: "{ a: '1', b: 2, c: true, d: false, e: undefined, f: null, g: { a: '1' } }", | ||
required: false, | ||
type: '{ [key: string]: any; }' | ||
}, | ||
sampleString: { | ||
defaultValue: 'hello', | ||
required: false, | ||
type: 'string' | ||
}, | ||
sampleTrue: { type: 'boolean', required: false, defaultValue: 'true' }, | ||
sampleUndefined: { | ||
defaultValue: 'undefined', | ||
required: false, | ||
type: 'any' | ||
} | ||
} | ||
}; | ||
it('should parse defined props', function () { | ||
testUtils_1.check('StatelessWithDefaultProps', expectation); | ||
}); | ||
it('should parse referenced props', function () { | ||
testUtils_1.check('StatelessWithReferencedDefaultProps', expectation); | ||
}); | ||
}); | ||
@@ -235,0 +268,0 @@ it('should parse functional component component defined as function', function () { |
@@ -35,7 +35,7 @@ "use strict"; | ||
var basePath = path.dirname(tsconfigPath); | ||
var _a = ts.readConfigFile(tsconfigPath, function (filename) { return fs.readFileSync(filename, 'utf8'); }), configJson = _a.config, error = _a.error; | ||
var _a = ts.readConfigFile(tsconfigPath, function (filename) { return fs.readFileSync(filename, 'utf8'); }), config = _a.config, error = _a.error; | ||
if (error !== undefined) { | ||
throw error; | ||
} | ||
var _b = ts.convertCompilerOptionsFromJson(configJson.compilerOptions, basePath, tsconfigPath), options = _b.options, errors = _b.errors; | ||
var _b = ts.parseJsonConfigFileContent(config, ts.sys, basePath, {}, tsconfigPath), options = _b.options, errors = _b.errors; | ||
if (errors && errors.length) { | ||
@@ -58,2 +58,5 @@ throw errors[0]; | ||
var sourceFile = program.getSourceFile(filePath); | ||
if (!sourceFile) { | ||
return []; | ||
} | ||
var moduleSymbol = checker.getSymbolAtLocation(sourceFile); | ||
@@ -289,3 +292,6 @@ if (!moduleSymbol) { | ||
} | ||
var propMap = getPropMap(properties); | ||
var propMap = {}; | ||
if (properties) { | ||
propMap = getPropMap(properties); | ||
} | ||
return propMap; | ||
@@ -299,3 +305,5 @@ } | ||
var properties = right.properties; | ||
propMap_1 = getPropMap(properties); | ||
if (properties) { | ||
propMap_1 = getPropMap(properties); | ||
} | ||
} | ||
@@ -302,0 +310,0 @@ }); |
{ | ||
"name": "react-docgen-typescript", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
94533
2.68%1194
3.56%