Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
631 changes: 0 additions & 631 deletions .yarn/releases/yarn-3.0.0.cjs

This file was deleted.

873 changes: 873 additions & 0 deletions .yarn/releases/yarn-3.5.0.cjs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
enableGlobalCache: true

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: '@yarnpkg/plugin-typescript'

yarnPath: .yarn/releases/yarn-3.0.0.cjs
yarnPath: .yarn/releases/yarn-3.5.0.cjs
15 changes: 8 additions & 7 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
const { defaults } = require('ts-jest/presets');
const path = require('path');

module.exports = {
testEnvironment: 'node',
transform: defaults.transform,
testRegex: `test/index.test.ts$`,
globals: {
'ts-jest': {
packageJson: path.join(__dirname, 'package.json'),
},
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
packageJson: path.join(__dirname, 'package.json'),
},
],
},
testRegex: `test/index.test.ts$`,
coveragePathIgnorePatterns: ['/node_modules/', '/.pnp.cjs'],
};
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-to-proptypes",
"packageManager": "yarn@3.0.0",
"packageManager": "yarn@3.5.0",
"version": "2.2.1",
"description": "Generate proptypes from typescript declarations",
"main": "dist/index.js",
Expand Down Expand Up @@ -39,12 +39,12 @@
"@types/uuid": "^8.0.0",
"glob": "^7.1.6",
"husky": "^4.2.3",
"jest": "^26.0.1",
"jest": "^29",
"prettier": "^2.0.1",
"pretty-quick": "^2.0.1",
"react": "^16.8.6",
"standard-version": "^8.0.0",
"ts-jest": "^26.1.0"
"ts-jest": "^29.1.0"
},
"dependencies": {
"@babel/core": "^7.11.1",
Expand All @@ -54,7 +54,7 @@
"doctrine": "^3.0.0",
"lodash": "^4.17.14",
"tslib": "^1.13.0",
"typescript": "3.8.3",
"typescript": "5.0.4",
"uuid": "^8.1.0"
},
"dependenciesMeta": {
Expand Down
4 changes: 2 additions & 2 deletions src/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ function plugin(
} else if (babelTypes.isExportNamedDeclaration(path.parent)) {
path.insertAfter(babel.template.ast(`export { ${nodeName} };`));
path.insertAfter(babel.template.ast(placeholder));
path.parentPath.replaceWith(path.node);
path.parentPath?.replaceWith(path.node);
} else if (babelTypes.isExportDefaultDeclaration(path.parent)) {
path.insertAfter(babel.template.ast(`export default ${nodeName};`));
path.insertAfter(babel.template.ast(placeholder));
path.parentPath.replaceWith(path.node);
path.parentPath?.replaceWith(path.node);
} else {
path.insertAfter(babel.template.ast(placeholder));
}
Expand Down
15 changes: 11 additions & 4 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,23 @@ export function parseFromProgram(
}
const componentName = node.name.getText();

if (symbol.valueDeclaration === undefined) {
return;
}

const type = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
type.getCallSignatures().forEach((signature) => {
if (!isTypeJSXElementLike(signature.getReturnType())) {
return;
}

const propsType = checker.getTypeOfSymbolAtLocation(
signature.parameters[0],
signature.parameters[0].valueDeclaration
);
const declaration = signature.parameters[0]?.valueDeclaration;

if (declaration === undefined) {
return;
}

const propsType = checker.getTypeOfSymbolAtLocation(signature.parameters[0], declaration);

parsePropsType(componentName, propsType, node.getSourceFile());
});
Expand Down
Loading