Comments (9)
I ran into the same issue! Here was my workaround:
#
# Helper script to generate a master Typescript definition file.
#
INPUT_FILES=src/components/*/index.js
OUTPUT_FILE=types/index.d.ts
regex='src/components/([A-Za-z]+)/index.js'
# Initialize the output file with a header
cat > $OUTPUT_FILE <<- EOM
// Type definitions for <my project>
// Project: <my project>
// Definitions by:
/// <reference types="my-project" />
EOM
# Loop through all input files and run react2dts on them,
# concatenating the output to our single output file
for file in $INPUT_FILES; do
[[ $file =~ $regex ]]
comp_name=${BASH_REMATCH[1]}
$(npm bin)/react2dts --file "$file" --name $comp_name >> $OUTPUT_FILE
done
from react-to-typescript-definitions.
Hi @artyomsv,
all current possible cases are in the various unit tests. Please have a look if there is something which fulfills your requirement. I'm not sure what you mean with do not want to declare module
.
Right now it is only possible to create dts for one file at once. But it should be quite simple to eiter loop through them with a simple bash command or use the JS API.
from react-to-typescript-definitions.
@KnisterPeter thanks for quick reply
Regarding declaring the module here is an example:
If I use your tool for JSX file I get something like this:
declare module 'name' {
import * as React from 'react';
export interface BaseInputCssModule {
...
}
export interface BaseInputProps {
.......
}
const BaseInput: React.SFC<BaseInputProps>;
export default BaseInput;
}
In my case I just want to place dts file together with my widget so I would expect to have index.d.ts file like:
export interface BaseInputCssModule {
...
}
export interface BaseInputProps {
...
}
declare const BaseInput: React.SFC<BaseInputProps>;
export default BaseInput;
from react-to-typescript-definitions.
Just add --top-level-module
to your cmdline
from react-to-typescript-definitions.
Hello, I am having the same issue, --top-level-module
seems to be ignored and it defaults same as I would do react2dts --module-name moduleName
, is there something I am missing? Thanks
from react-to-typescript-definitions.
@bartholomews I have no clue. Can you please add your whole commandline you execute with all parameters and any output you get to this issue?
from react-to-typescript-definitions.
@sinnerschrader I think I have found the issue, it's defaulting only if the flag is set without value, if followed by any value it seems to work:
So it's not a big deal for us I think 👍
from react-to-typescript-definitions.
@bartholomews Intersting find. I'll flag this as bug as it should be fixed. But you already have your workaround. Thanks for sharing.
from react-to-typescript-definitions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from react-to-typescript-definitions.
Related Issues (20)
- Just the first export is processed if a file contains multiple exports HOT 2
- Not recognizing back quotes as quotes HOT 2
- Enable optional chaining in babylon parser HOT 2
- namespaces for components HOT 1
- undefined prop name for nested props HOT 2
- don't generate types for wrapped components HOT 1
- Dependency security issue HOT 2
- Failed to lookup identifier for imported PropTypes HOT 2
- Failed to lookup shape properties HOT 2
- Error on trying to catch a type-resolving error
- Action Required: Fix Renovate Configuration
- Dependency deprecation warning: babel-preset-es2015 (npm) HOT 1
- Feature request: make babylon plugins configurable HOT 2
- Feature request: make eol configurable HOT 3
- Triple slash directive is broken #469 HOT 13
- Support for commonjs output HOT 2
- Return empty prop list when I try to use propTypes from other components HOT 4
- Generating a single type definition file for non-Typescript components HOT 2
- Jsdoc is not generated HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-to-typescript-definitions.