-
Notifications
You must be signed in to change notification settings - Fork 15
type definitions without module #624
Comments
Hi @artyomsv, 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. |
@KnisterPeter thanks for quick reply 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; |
Just add |
Hello, I am having the same issue, |
@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? |
@bartholomews Intersting find. I'll flag this as bug as it should be fixed. But you already have your workaround. Thanks for sharing. |
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 |
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. |
Hi,
I have multiple Scenarios and not sure if your library support them:
Do you have and examples how I can achieve this with react2dts?
Thanks in advance!
Artyom
The text was updated successfully, but these errors were encountered: