@oeyoews/tw5-typed
v0.4.4
Published
Types for tiddlywiki
Downloads
1
Readme
TW5-Typed
TypeScript type definitions for TiddlyWiki5.
Usage
First, install it as dev-dependency:
npm i -D tw5-typed
Add tw5-typed
to your tsconfig.json
's compilerOptions
{
"compilerOptions": {
"types": ["node", "tw5-typed"] /* Type declaration files to be included in compilation. */
}
}
Then you will have global types like $tw
automatically. You can import the rest of the types using import type
statement:
import type { ISearchOptions, SourceIterator, IFilterOperatorParamOperator } from 'tiddlywiki';
Alias
Sometimes you may want to use a modified version of tw, you can re-export types like this in your src/type.d.ts
:
declare module '@tiddlygit/tiddlywiki' {
export * from 'tiddlywiki';
}
Development
Firstly, Install eslint using npm:
npm i
You can add new *.d.ts
file to contain your types:
- use
declare module 'tiddlywiki' { }
to wrap all your types. - don't forget to
export
all your types. - to add type for global variable, add
global { }
inside thatdeclare module 'tiddlywiki' { }
, likeglobal { var $tw: I$TW; }
- add type import like
/// <reference path="ast.d.ts" />
in thetw.d.ts
Importing type from other files
- add type import like
/// <reference path="parser.d.ts" />
- using normal import, like
import { parse } from './parser';
will not work
Test in your node_modules
To rapid prototype the type, just right click a type to open .d.ts
file in the node_modules
, and try create new file there, and copy to this repo after a success.