Skip to content

Commit

Permalink
Type TokenList
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Mar 11, 2020
1 parent e8a7520 commit 106e302
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
39 changes: 36 additions & 3 deletions packages/token-list/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,42 @@ export default class TokenList {
constructor( initialValue = '' ) {
this.value = initialValue;

[ 'entries', 'forEach', 'keys', 'values' ].forEach( ( fn ) => {
this[ fn ] = ( ...args ) => this._valueAsArray[ fn ]( ...args );
} );
// Disable reason: These are type hints on the class.
/* eslint-disable no-unused-expressions */
/** @type string */
this._currentValue;

/** @type string[] */
this._valueAsArray;
/* eslint-enable no-unused-expressions */
}

/**
* @param {Parameters<Array<string>['entries']>} args
*/
entries( ...args ) {
return this._valueAsArray.entries( ...args );
}

/**
* @param {Parameters<Array<string>['forEach']>} args
*/
forEach( ...args ) {
return this._valueAsArray.forEach( ...args );
}

/**
* @param {Parameters<Array<string>['keys']>} args
*/
keys( ...args ) {
return this._valueAsArray.keys( ...args );
}

/**
* @param {Parameters<Array<string>['values']>} args
*/
values( ...args ) {
return this._valueAsArray.values( ...args );
}

/**
Expand Down
4 changes: 1 addition & 3 deletions packages/token-list/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build-types",
"strictNullChecks": false,
"noImplicitAny": false
"outDir": "build-types"
},
"include": [ "src/**/*" ]
}

0 comments on commit 106e302

Please sign in to comment.