-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add typescript declarations formats #557
Conversation
feat(formats): add typescript/module-declarations formats for .d.ts
docs(formats): add typescript/module-declarations docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added note to doc comment about extending style-dictionary to generate 100% accurate .d.ts files.
**Example** | ||
```typescript | ||
export default tokens; | ||
declare interface DesignToken { value: string; name?: string; path?: string[]; comment?: string; attributes?: any; original?: any; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not perfect solution but will work for most cases.
I'm currently working on way to optimise this without bringing third party libraries like json-to-ts.
This looks pretty solid. Let me go over it one more time with @dbanksdesign on Wednesday and we can merge it in. Thanks so much for all the re-arrangement with the 3.0 branch! |
|
||
var file = fileHeader(this.options) + | ||
'export default tokens;\n' + | ||
'declare interface DesignToken { value: string; name?: string; path?: string[]; comment?: string; attributes?: any; original?: any; }\n' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @Tiamanti, one more question for you...
The DesignToken interface and the Prop interface are fairly similar - minus optional fields.
Is there a way to tie these together somehow so that we use a single source of truth? Or combine them?
If we decide to change the structure later by adding additional metadata properties, it would be nice to only have one place to fix.
I apologize again if my TypeScript naivety is showing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tiamanti did you have thoughts here?
We will likely do another release candidate of 3.0 here shortly - and it might be the last one. Would love to get this PR in as part of that.
Thanks for all your hard work!
*Issue #425
Description of changes:
feat(formats): add typescript/es6-declarations formats for .d.ts
feat(formats): add typescript/module-declarations formats for .d.ts
docs(formats): add typescript/es6-declarations docs
docs(formats): add typescript/module-declarations docs
Notes:
Per @chazzmoney request cherrypicked this to 3.0 branch.
Closed #542
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.