Skip to content
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

Merged
merged 3 commits into from
May 12, 2021
Merged

add typescript declarations formats #557

merged 3 commits into from
May 12, 2021

Conversation

Tiamanti
Copy link
Contributor

@Tiamanti Tiamanti commented Mar 7, 2021

*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.

Tiamanti and others added 3 commits March 7, 2021 19:54
feat(formats): add typescript/module-declarations formats for .d.ts
docs(formats): add typescript/module-declarations docs
Copy link
Contributor Author

@Tiamanti Tiamanti left a 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; }
Copy link
Contributor Author

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.

@chazzmoney
Copy link
Collaborator

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' +
Copy link
Collaborator

@chazzmoney chazzmoney Mar 13, 2021

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.

Copy link
Collaborator

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants